Write a program in C language which does not have even a single semicolon, but prints ‘Hello World‘.
Semicolon is used to terminate a statement in C language, null statement (Statement that does nothing) can be written in two ways:
; // Empty or NULL Statement {} // Empty of NULL Statement
The below program uses this fact, to print ‘Hello World without having any semicolon in it:
#include int main() { while( ! printf("Hello World") ) { } }
Output:
Hello World
Note that printf returns the number of characters printed. In this case ptintf will return 11 (including the space character). 11 in C language is true, NOT of true is false. Hence, control will not enter loop even once (And’Hello World‘ will be printed only once).
1 Comment
Print ‘Hello World’ without using semicolon
[url=http://www.christianlouboutins-outlet.com]christian louboutin outlet[/url]