C++ ASCII Value
C++ ASCII Value
#include <iostream>
using namespace std;
int main() {
char c = 'A';
int ascii_value = c;
cout << "The ASCII value of " << c << " is " << ascii_value;
return 0;
}
- Include the necessary header file for input/output operations.
- Define the main function.
- Declare a character variable
c
and initialize it with the character 'A'. - Declare an integer variable
ascii_value
. - Assign the ASCII value of the character
c
to the variableascii_value
. - Output the ASCII value of the character
c
using thecout
statement.
This code snippet calculates and displays the ASCII value of the character 'A'.