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;
}
  1. Include the necessary header file for input/output operations.
  2. Define the main function.
  3. Declare a character variable c and initialize it with the character 'A'.
  4. Declare an integer variable ascii_value.
  5. Assign the ASCII value of the character c to the variable ascii_value.
  6. Output the ASCII value of the character c using the cout statement.

This code snippet calculates and displays the ASCII value of the character 'A'.