ASCII value of character

The term ASCII (American Standard Code for Information Interchange) refers to a defined character encoding. It assigns certain codes to characters such as letters, digits and punctuation marks. The ASCII code is used to specify how the characters are displayed by electronic devices – such as PCs or smartphones. This is an important part of many programming operations

Code Explanation

LineDescription
5Creates the variable c of type char
7Prompts the user to enter a character of type char
8The value is stored in the variable named c
10Outputs the ASCII value of the character c by outputting the integer value of the character with the int() function
#include <iostream>
using namespace std;

int main () {
    char c;

    cout << "Please enter character: ";
    cin >> c;

    cout << "ASCII value of the character " << c << " is: " << int(c);
    
    return 0;
}
Output
Please enter character: u
ASCII value of the character u is: 117