C++ Program to Print ASCII Value of a Character

In this program, you'll learn to print ASCII value of a character. ASCII is the American Standard Code for Information Interchange a character encoding scheme used for electronics communication. Each character or a special character is represented by some ASCII code, and each ascii code occupies 7 bits in memory. For example, the ascii value of 'A' is 65. In the below example, we assign 'A' to the character variable whose ascii value is 65, so 65 will be stored in the character variable rather than 'A'.

Source Code
using namespace std;

int main(int argc, char const *argv[])
    char c;
    int v;
    cout<<"Enter any character: ";
    cin>> c;
    v = c;
    cout<<"The ASCII value is: " << v;
    return 0;
Enter any character: A
The ASCII value of A is 65

Enter any character: Q
The ASCII value of Q is 81