C Program to Find ASCII Value of a Character
This post helps to find ASCII value for a character using the C programming language. Let’s start looking at the source code.
C Program to Find ASCII Value of a Character
#include<stdio.h> int main() { char c; //GET THE ASCII VALUE FROM THE USER printf("ENTER THE CHARACTER:"); scanf("%c",&c); //DISPLAY THE CHARACTER //%d is for integer and %c is for character printf("ASCII value of %c=%d",c,c); return 0; }
Output
Capital letter ASCII value

Small letter ASCII value

Explanation
Here this C program helps us find ASCII value for a character, here we get the character from the user, and the character value gets stored in the variable named “c.”
printf("ENTER THE CHARACTER:"); scanf("%c",&c);
After allowing the user to enter the character, we proceed to display the required result using the “printf” statement. The user-defined value gets stored in the variable named “c.”
//%d is for integer and %c is for character printf("ASCII value of %c=%d",c,c);
Here we use the modulus operator as “%c” which displays the character value and “%d” which displays the integer value.
1 Comment
Good work