C Program to print "hello" without semicolon

In C, we can print anything without the use of a semicolon, including "hello" and "hello world". There are several methods to do this:

  1. Using if
  2. Using switch
  3. Using loop etc.

Program 1: Using if statement

#include<stdio.h>  

 int main()    

{    

 if(printf("hello world")){}    

return 0;  

}   

Output:

hello world

Program 2: Using switch statement

#include<stdio.h>  

 int main()    

{    

switch(printf("hello world")){}    

return 0;  

}   

Output:

hello world

Program 3: Using while loop

#include<stdio.h>  

 int main()    

{    

   while(!printf("hello world")){}    

return 0;  

}   

Output:

hello world



Post a Comment

Previous Post Next Post