Learn about C program to display the ASCII value of a character in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.
Contents
C program to display the ASCII value of a character
ASCII is a short form for American Standard Code for Information Interchange. The American National Standards Institute (ANSI) created ASCII (American National Standards Institute). ASCII is used to transfer data from a high-level language to a low-level one. Only binary languages are understood by machines and computers. As a result, the character data type is used to represent numbers.
Given a character, the below program prints the corresponding ASCII value.
Program:
#include<stdio.h>
int main()
{
char ch;
printf("Enter any character: ");
scanf("%c",&ch);
printf("ASCII value of %c is = %d",ch,ch);
return 0;
}
Output:
Enter any character: d
ASCII value of d is = 100
Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.
Similar Codes :
C Program to find Area of a triangle having three sides
C program to find the area of a Rectangle