C Program to Print ASCII Value of a Character

In this program, you'll learn to print ASCII value of a character. ASCII is the American Standard Code for Information Interchange a character encoding scheme used for electronics communication. Each character or a special character is represented by some ASCII code, and each ascii code occupies 7 bits in memory. For example, the ascii value of 'A' is 65. In the below example, we assign 'A' to the character variable whose ascii value is 65, so 65 will be stored in the character variable rather than 'A'.

Source Code

int main(int argc, char const *argv[])
    char c;
    printf("Enter any character: ");
    scanf("%c", &c);
    printf("The ASCII value of %c is %d", c, c);
    return 0;
Enter any character: A
The ASCII value of A is 65

Enter any character: Q
The ASCII value of Q is 81

"Coding Hub - Learn to code" app now available on Google Play Store