Saturday, February 5, 2011

printing something without using semicolon in the program

Program to print some thing with out using semicolon(;)
#include <stdio.h>
void main() {
//printf returns the length of string being printed
if (printf("Hello World\n")) //prints Hello World and returns 11
{
//do nothing
}
}
Output:
Hello World
Explanation:
The if statement checks for condition whether the return value of printf("Hello World") is greater than 0. printffunction returns the length of the string printed. Hence the statement if (printf("Hello World")) prints the string "Hello World".

No comments:

Post a Comment

Feel free to comment......