12
A C Program without a semicolon to print the length of a string

Here is a small code without a semicolon:

#include <stdio.h>                              
void main()  
{  
        if(printf("\nString length: %d\n",printf("Welcome to the world of programming")))   
        {}  
}

printf() returns the number of characters it successfully prints on the screen. Hence the inner printf() function in if statement returns a value 35 in this case and outer printf() function prints String length: 35. Since outer printf() function returns a non-zero value , the if statement results in TRUE and the program executes nothing as the block is intentionally left blank.

Note: The concept of stack is used here wherein the second printf() function is the first to be executed (LIFO) .

OUTPUT:
Welcome to the world of programming
String length: 35

?