Home Lifestyle C Program to Find ASCII Value of a Character

C Program to Find ASCII Value of a Character


C Program to Find ASCII Value of a Character. In this Article you will learn how to find the ASCII value of a character. To understand this example, you should have the knowledge of the following C programming topics:

  • C Data Types
  • C Variables, Constants and Literals
  • C Input Output (I/O)

In C programming, a character variable holds ASCII value (an integer number between 0 and 127) rather than that character itself. This integer value is the ASCII code of the character.

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.

Program to Print ASCII Value

#include <stdio.h>
int main() {  
    char c;
    printf("Enter a character: ");
    scanf("%c", &c);  
    // %d displays the integer value of a character
    // %c displays the actual character
    printf("ASCII value of %c = %d", c, c);
    return 0;


Enter a character: G
ASCII value of G = 71
<img decoding=

Types of Sorting Algorithms:

Additional Reading


If you found this post useful, don’t forget to share this with your friends, and if you have any query feel free to comment it in the comment section.

Thank you 😊 Keep Learning !

Previous articleC Program to Multiply Two Floating-Point Numbers (updated)
Next articleSum of Digits of a Number in Java Program


Please enter your comment!
Please enter your name here