write a program to print the ascii value of given character

We know that Ascii stands for American Standard Code for Information Interchange. it is a character-encoding scheme. It is based on the English alphabet, every character or number have its own Ascii value for such as Ascii value of a is 97.

The code for this program is as follows:


void main()
int number, result;
cout <<"Enter any Character :";
number = getch();
result = toascii(number);
cout <<"Ascii value: "<<result;

#include<iostream.h> used for input/output of data
#include<conio.h> provides several functions like clrscr(), getch() etc.
After that in main() function we have declared a variables number, result; after that we have used clrscr(); function to clear the scree when program will run. It will clear the previous output from any program. Now we have used the cout function that shows message “Enter any Character :”; and when we enter any char then this char is read by getch() function and assign to number variable.
Here we have used toascii() function which is predefined function in "ctype.h" header file which gives or return Ascii value of any given value.
The output is as follows:

c++ program