Home >>Cpp Programs >C++ Program to Find ASCII Value of a Character
In this example, we will see a C++ program through which we can print character through ASCII value.
When we pass an integer value to cout then it prints the value in decimal format and if we want to print a character using the ASCII value then cout will not print the character normally.
We will use the cast type in this program, we can use cout<<char(var), which will print the ASCII value of (var).
Program:
#include <iostream>
using namespace std;
int main()
{
//loop counter
int i;
for(i='A'; i<='Z'; i++)
cout<<"CHAR: "<<(char)i<<" ASCII: "<<i<<endl;
return 0;
}