#include<iostream>
using namespace std;
int main()
{
char ch;
cout<<"\nEnter any character : ";
cin>>ch;
cout<<"ASCII equivalent is : "<<static_cast<int>(ch);
return 0;
}
OUTPUT:
Enter any character : A
ASCII equivalent is : 65
Hint: Here we used static_cast<int>(ch) .. Well static_cast is in built function in c++ . This function in simple english is converting a character (ch) into integer <int> which is also ASCII code for that character.
You will hardly get to ask the use of static_cast in class 12th. But you should better do more research for future references.
No comments:
Post a Comment