Q:

C Program to print "hello" without semicolon

belongs to collection: C Programs

0

We can print "hello" or "hello world" or anything else in C without using semicolon. There are various ways to do so:

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

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program 1: Using if statement

Let's see a simple c example to print "hello world" using if statement and without using semicolon.

#include<stdio.h>  
 int main()    
{    
 if(printf("hello world")){}    
return 0;  
}   

Output:

hello world

Program 2: Using switch statement

Let's see a simple c example to print "hello world" using switch statement and without using semicolon.

#include<stdio.h>  
 int main()    
{    
switch(printf("hello world")){}    
return 0;  
}   

Output:

hello world

 

Program 3: Using while loop

Let's see a simple c example to print "hello world" using while loop and without using semicolon.

#include<stdio.h>  
 int main()    
{    
   while(!printf("hello world")){}    
return 0;  
}   

Output:

hello world

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Assembly program in C... >>
<< C Program to swap two numbers without third variab...