C++ Program to enter a character and output its ASCII code

Program to enter a character and output its ASCII code

#include <iostream.h>
#include <conio.h>

void main()
{
clrscr();
char charac;
cout << "Enter the character : " << endl;
cin>>charac;
int num1=charac;
cout << "The ASCII code for " << charac << " is " << num1 << "." << endl;
getch();
}
This program takes in any character charac as a screen input from the user.
It then finds out its ASCII code and outputs it using the 'cout' command.

OUTPUT

The ASCII code for a is 97.

Next Post Previous Post
No Comment
Add Comment
comment url
We detected that you're using an AdBlocker. Please disable it and refresh to continue using our website.
Ad