Q:

Write a C++ Program to Display ASCII Value of a Character

belongs to collection: C++ Basic Solved Programs

0

Write a C++ Program to Display ASCII Value of a Character. Here’s simple C++ Program to Find ASCII Value of a Character in C++ Programming Language.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

A character variable holds ASCII value (an integer number between 0 and 127) rather than that character itself in C programming. That value is known as ASCII value.

 
 

For example, ASCII value of ‘A’ is 65.

What this means is that, if you assign ‘A’ to a character variable, 65 is stored in that variable rather than ‘A’ itself.


Here is source code of the C++ Program to Display ASCII Value of a Character. The C++ program is successfully compiled and run(on Codeblocks) on a Windows system. The program output is also shown in below.

 

SOURCE CODE : :

/*  C++ Program to Display ASCII Value of a Character  */

#include <iostream>
using namespace std;

int main()
{
     char c;

     cout << "Enter any Character :: ";
     cin >> c;

     cout << "\nThe ASCII Value of Character [ "<< c << " ] is :: " << int(c)<<"\n";

     return 0;
}

Output : :


/*  C++ Program to Display ASCII Value of a Character  */

Enter any Character :: C

The ASCII Value of Character [ C ] is :: 67

Process returned 0

Above is the source code for C++ Program to Display ASCII Value of a Character which is successfully compiled and run on Windows System.The Output of the program is shown above .

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C++ Basic Solved Programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
C++ Program to Generate Random Numbers between 0 a... >>
<< Write a C++ Program to Calculate Multiplication of...