A
' is 65
.A
' to a character variable, 65
is stored in the variable rather than 'A
' itself.#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: L
ASCII value of L = 76
%d
format string is used, 76
(the ASCII value of L
) is displayed.%c
format string is used, 'L
' itself is displayed.