Home C Programming Tutorial C Program to Find ASCII Value of a Character

C Program to Find ASCII Value of a Character

by Anup Maurya
10 minutes read

In this example, you will learn how to find the ASCII value of a character.

What is ASCII code?

ASCII stands for American Standard Code for Information Interchange. ASCII is a character encoding system that is used for telecommunication. There are 256 ASCII characters, but we only use 128 characters (0 to 127). These include lowercase letters, uppercase letters, numbers, punctuation symbols, etc.

Every character has an ASCII value associated with it. Characters are stored in the memory using their ASCII values in C. 

For example, the ASCII value of 'A' is 65.

What this means is that, if you assign 'A' to a character variable, 65 is stored in the variable rather than 'A' itself.

Now, let’s see how we can print the ASCII value of characters in C programming.

C Program to Find ASCII Value of a Character

#include < stdio.h >

int main() {
    char ch;

    // assigning a letter to ch
    printf("Enter the Character: ");
    scanf("%c", & ch);

    // displaying the ASCII value of the letter stored in ch
    printf("\nThe ASCII Value of %c is %d", ch, ch);

    return 0;
}

Input

Enter the Character: z

Output

The ASCII Value of z is 122

related posts

Leave a Comment

Enable Notifications OK No thanks