C++ program to display ASCII code of a character and vice versa.
Q35. Write a c++ program to display ASCII code of a character and vice versa.
Ans.
#include<iostream.h>
#include<conio.h> //for clrscr()
void main()
{
char ch=’A’; //assign ASCII code for ‘A’ to ch
int num=ch; //store same code in an int
clrscr(); //for clear screen
cout<<“\n The ASCII code for “<<ch<<” is “<<num;
cout<<“\n Adding 1 to the character code: “;
ch=ch+1;
num=ch;
cout<<“\n The ASCII code for “<<ch<<” is “<<num;
}
Output
The ASCII code for A is 65
Adding 1 to the character code:
The ASCII code for B is 66