How to print a semicolon(;) without using semicolon in C/C++?



In this tutorial, we will be discussing a program to understand how to print a semicolon(;) without using a semicolon in /C++.

This can be done in two possible ways, either by using the ascii value of semicolon or using user-defined macros for the same.

Example

 Live Demo

Using putchar() method

#include <stdio.h> int main(){    //ASCII value of semicolon is equal to 59    if (putchar(59)){    }    return 0; }

Output

;

Example

 Live Demo

Using Macros :

#include <stdio.h> #define POINT printf("%c",59) int main(){    if (POINT) {    } }

Output

;
Updated on: 2020-03-02T10:38:18+05:30

340 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements