C++ Program to Find ASCII Value of a Character

There are 128 characters in the ASCII (American Standard Code for Information Interchange) table with values ranging from 0 to 127.

Some of the ASCII values of different characters are as follows −

CharacterASCII Value

A program that finds the ASCII value of a character is given as follows −


 Live Demo

#include <iostream>
using namespace std;
void printASCII(char c) {
   int i = c;
   cout<<"The ASCII value of "<<c<<" is "<<i<<endl;
int main() {
   return 0;


The ASCII value of A is 65
The ASCII value of a is 97
The ASCII value of Z is 90
The ASCII value of z is 122
The ASCII value of $ is 36
The ASCII value of & is 38
The ASCII value of ? is 63

In the above program, the function printASCII() prints the ASCII values of characters. This function defines an int variable i and the value of the character c is stored into this variable. Since i is integer type, the corresponding ASCII code of the character is stored into i. Then the values of c and i are displayed.

This is demonstrated by the following code snippet.

void printASCII(char c) {
   int i = c;
   cout<<"The ASCII value of "<<c<<" is "<<i<<endl;
karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know