In this post, we are going to write a C++ program to print the ASCII value of a character. user will enter a number and the program will print the character or given number after that user will enter a character and the program will print the numeric value of the given character.
C++ program to print the ASCII value of a character.
#include<iostream> #include<conio.h> int main(void) { int n,n1; char ch,ch1; std::cout<<"Enter any number = "; std::cin>>n; ch=n; std::cout<<"The character of given number is = "<<ch<<std::endl; std::cout<<"Press any character on the keyboard = "; std::cin>>ch1; n1=ch1; std::cout<<"The numeric value of given character is = "<<n1; return 0; }
Output
Enter any number = 65 The character of given number is = A Press any character on the keyboard = g The numeric value of given character is = 103