
Generally when use printf("") statement we have to use semicolon
at the end.
If we want to print a semicolon, we use the statement:
printf(";");
In above statement, we are using two semicolons. The task of printing a
semicolon without using semicolon anywhere in the code can be accomplished
by using the ascii value of ' ; ' which is equal to 59.
Program: Program to print a semicolon without using 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(;).
|
This page was last modified on 15 Dec 2011 at 19:44:10. |
Gautam Kumar EDP Manager |
» C program to generate the Fibonacci series
» C program to print a semicolon without using a semicolon
» C program to compare two strings without using strcmp
» C program to concatenate two strings without using strcat
» C program to delete a specified line from a text file
» C program to replace a specified line in a text file
» C program to find the number of lines in a text file
» C program which asks the user for a number between 1 to 9
» C program to check whether the given string is a palindrome
» C program to check whether the given number is a palindromic
» C program to find factorial of the given number
» C program to check whether the given number is even or odd
» C program to swap two numbers using a temporary variable
» C program to swap two numbers using bitwise operators
» C program to find the greatest of three numbers
» C program to find the greatest among ten numbers
» C program to check whether the given number is a prime
» How to create pyramid in c
» Fun with C language.
