Search Your Topic

config
Monday, 12 June 2017 13:27

C Program to print "hello" without semicolon

Written by
Rate this item
(0 votes)

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.

Program 1: Using if statement

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

 
  1. #include<stdio.h>  
  2. void main(){  
  3.    if(printf("hello world")){}  
  4. }  

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.

 
  1. #include<stdio.h>  
  2. void main(){  
  3.    switch(printf("hello world")){}  
  4. }  

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.

 
  1. #include<stdio.h>  
  2. void main(){  
  3.    while(!printf("hello world")){}  
  4. }  

Output:

hello world
Read 410 times
Anish Sir

"I am delighted once again to pen the welcome note to the Tosh!Yas Technologies ."

 Call +91 74 88 34 7779  | Email : anishsingh@live.com

toshiyas.in
More in this category: « C Programs Pointers »

Leave a comment

Make sure you enter all the required information, indicated by an asterisk (*). HTML code is not allowed.