The Program in C to print ASCII code of any character is given below:
#include <stdio.h>
int main() {
char c;
printf("Enter a character: ");
scanf("%c", &c);
printf("The ASCII code of '%c' is %d", c, c);
return 0;
}
Output:
Enter a character: G
The ASCII code of ‘G’ is 71
Pro-Tips💡
This program uses the scanf
function to read a character input by the user and store it in the variable c
.
The printf
function is then used to print the character and its corresponding ASCII code, which is represented by the variable c
.
Learn C-Sharp ↗
C-sharp covers every topic to learn about C-Sharp thoroughly.
Learn C Programming ↗
C-Programming covers every topic to learn about C-Sharp thoroughly.
Learn C++ Programming↗
C++ covers every topic to learn about C-Sharp thoroughly.