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 <stdio.h>
  2. int main()
  3. {
  4. char c;
  5. printf("Enter a character: ");
  6. scanf("%c", &c);
  7. // %d shows the integer value for the character
  8. // %c displays the actual character
  9. printf("ASCII value of %c = %d", c, c);
  10. return 0;
  11. }

Output:

Enter a character: A
ASCII value of A = 65