Program to Find ASCII Value of a Character - ( C Programs )
Example
#include <stdio.h>
int main() {
char ch;
printf("Enter a character: ");
scanf("%c", &ch);
printf("ASCII value of %c = %d\n", ch, ch);
return 0;
}
Output
Enter a character: A
ASCII value of A = 65
Explanation
ASCII stands for American Standard Code for Information Interchange. It is a character encoding that assigns unique numerical values to each alphabetic, numeric, and special symbol character in the English language, as well as control codes for hardware control.
The ASCII value of a character can be found by converting the character to its corresponding decimal value from the ASCII table.
In this program, the user is prompted to enter a character. The scanf()
function is used to read the character input. The ASCII value of the entered character is then printed using the %d
format specifier.
Use
This program can be used to find the ASCII value of any character entered by the user. The ASCII values are commonly used in computer programming to represent characters in a text file or for communication between different devices.
Summary
In this program, we have learned how to find the ASCII value of a character in C programming language. The program takes user input as a character and then uses built-in functions to find and print the ASCII value of that character.