A Program to Find ASCII Value

In this example, we are giving a program to find ASCII value for a given character. A character variable contains a value instead of that character itself in C Programming. This value is known as ASCII value.


Program to find the ASCII value:

  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. char c;
  6. cout("Enter a character: ";
  7. cin >> c;
  8. cout << "ASCII value of " << c << " is " << int(c);
  9. return 0;
  10. }

Output:

Enter a character: A
ASCII value of A = 65