Print a semicolon without using semicolon anywhere in the program

Write a program to print a semicolon without using semicolon anywhere in the program.


 

Method 1: (Using printf/putchar)

The idea is to use ASCII value of semicolon inside printf() function to print semicolon print a semicolon without using semicolon. We can call print() function inside IF’s conditional expression with empty body to avoid using semicolon. When the conditional expression is evaluated, it will print semicoln on the screen. We can also use putchar() function in place of printf().

C implementation –

 
We can also use a while loop if conditional statements are not allowed in the program.

 

Method 2: (Using cout)
C++ implementation –

 
Thanks for reading.




Please use ideone or C++ Shell or any other online compiler link to post code in comments.
Like us? Please spread the word and help us grow. Happy coding 🙂