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

29 Dec 2022 Balmiki Kumar 0 C Programming

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

Generally when using printf("") statement we have to use a semicolon at the end. If we want to print a semicolon, we use the statement: printf(";"); In the above statement, we are using two semicolons.

The task of printing a semicolon without using a semicolon anywhere in the code can be accomplished by using the ASCII value of '; ' which is equal to 59.

Program 01: C Program to print a semicolon without using a semicolon in the code.

include<stdio.h>
int main(void) {
 //prints the character with ascii value 59, i.e., semicolon
 if (printf("%c\n", 59)) {
 //prints semicolon
 }
 return 0;
}

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(;).

BY: Balmiki Kumar

Related Blogs

Post Comments.

Login to Post a Comment

No comments yet, Be the first to comment.