Program for ASCII value for a character entered by user in C++

 Program for ASCII value for a character:



#include<iostream>
using namespace std;
int main ()
{
char a;
cout<<"enter value for a";
cin>>a;
cout<<"ASCII value of "<<a<<" is "<<int(a);
return 0;
}

output :
enter value for a  q
ASCII value of q is 113

here, int(a) is a function used to find the ASCII value of an character.

Comments