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
Line | Description |
---|---|
5 | Creates the variable c of type char |
7 | Prompts the user to enter a character of type char |
8 | The value is stored in the variable named c |
10 | Outputs 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;
}
Please enter character: u
ASCII value of the character u is: 117