Home »
C solved programs »
C basic programs
C - Print ASCII value of entered character
In this C program, we will read a character values in a character variable and then store its ASCII value to an integer variable.
It’s really very easy to convert a character value to an integer variable, consider the given statement,
integer_variable = (int)character_variable;
Print ASCII value of entered character in C
/*C - Print ASCII value of entered character.*/
#include <stdio.h>
int main(){
char ch;
int asciiValue;
printf("Enter any character: ");
scanf("%c",&ch);
asciiValue=(int)ch;
printf("ASCII value of character: %c is: %d\n",ch,asciiValue);
}
Output
Enter any character: x
ASCII value of character: x is: 120
C Basic Programs »