C program to print 'Hello World!' without using a semicolon

In this program, we will learn how to print any message without using semicolon (;) ?, as we all knows that we can print message using printf statement and printf statement terminates with semicolon.

Printing 'Hello World!' without using a semicolon

Here is a trick to print message without terminating statement by semicolon (;) – Call printf statement within the if condition and there is no need to terminate printf statement with semicolon (;) in if condition.

C program to print 'Hello World!' without using a semicolon

/*Program to print "Hello C" using if and else 
statement both.*/
 
#include <stdio.h>

int main() 
{ 

    if(!printf("Hello ")) 
        ; 
    else
        printf("C\n"); 

    return 0; 
}

Output

Hello C

Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.