ASCII Value

ASCII (American Standard Code for Information Interchange) is the character encoding standard of electronic communication. ASCII codes represent text within computers, telecommunications equipment, and other devices. – Wikipedia

Logic

To find ASCII value of a character we only have to cast them to integer data type. If the character is cast to integer data type then it automatically returns its ASCII value.

Casting is a way to convert a variable from one data type to another data type.

Program

#include <iostream>

using namespace std;

int main() {

    int a;
    char ch;

    cout << "Enter any character : ";

    cin >> ch;

    a = ch;

    cout << endl << "ASCII value of " << ch << " is " << a;

    return 0;
}

Output

Enter any character : a
ASCII value of a is 97