C Program to Find ASCII Value of a Character
#include <stdio.h>
int main()
{
char ch;
printf(“Enter a character: “);
scanf(“%c”, &ch);
printf(“ASCII value of %c = %d”, ch, ch);
return 0;
}
Explanation
char ch;→ Declares a character variable.scanf("%c", &ch);→ Reads a character from the user.printf("%d", ch);→ Displays the ASCII value of the character.- For example, the ASCII value of A is 65, B is 66, and a is 97.