ASCII value in C
Here’s a C program that finds the ASCII value of a character
#include
int main() {
char character;
printf("Enter a character: ");
scanf("%c", & character);
printf("The ASCII value of '%c' is %d.\n", character, character);
return 0;
}
Output

In this program, we declare a
character
variable of typechar
to store the input character from the user.The user is prompted to enter a character using the
printf
function, and thescanf
function is used to read the input and store it in thecharacter
variable.To find the ASCII value of the character, we simply pass the
character
variable toprintf
using the%c
format specifier to display the character itself, and%d
format specifier to display its corresponding ASCII value.Finally, the program displays the ASCII value of the entered character using
printf
.
