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 –

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)


Thanks for reading.

Please use our online compiler to post code in comments. To contribute, get in touch with us.
Like us? Please spread the word and help us grow. Happy coding 🙂

Leave a Reply

Notify of