C++ program to find character ASCII value
In this C++ program tutorial our task is to:
Write a C++ program to find the ASCII value of the given character.
C++ program to find the ASCII value of the given character
Given below is the C++ program in which a user input of char data type is accepted and then it is type casted to int data type and the following ASCII code is obtained.
using namespace std;
cout<<"Enter a character"<<endl;
cout<<"The ASCII value of the given character is"<<endl;
cout<<int(s); //Type casted from char data type to int data type.
Enter a character
The ASCII value of the given character is
In the above code the compilation starts from the main function (here int main()) .
Then it takes a character as a input .
By typecasting the char data type to int data type.
When we change a character to its integer format then the ASCII value of the corresponding character gets printed out.
You can see the above code execution and output in codeblocks IDE:
Would you like to see your article here on tutorialsinhand.
program by tutorialsinhand.com
About the Author
- 🔭 I’m currently working on DS Algo skills
- 🌱 I’m currently learning web develeopement
- 👯 I’m looking to collaborate with Oppia
- 📫 Reach me at https://www.linkedin.com/in/sayantan-bose-14134a1a6/
- 😄 Pronouns: his/him
Page Views :
Published Date :