Saturday, February 5, 2011

Program to print a semicolon without using semicolon in the code.

Program to print a semicolon without using semicolon in the code.
#include <stdio.h>
void main() {
//prints the character with ascii value 59, i.e., semicolon
if (printf("%c\n", 59)) {
//prints semicolon
}
}
Output:
;
Explanation:
If statement checks whether return value of printf function is greater than zero or not. The return value of function
call printf("%c",59) is 1. As printf returns the length of the string printed. printf("%c",59) prints ascii value that
corresponds to 59, that is semicolon(;).

No comments:

Post a Comment

Feel free to comment......