Program To Print Ascii Value Of A Character C

Program to Print ASCII Value of a Character in C

Understanding ASCII Values

In computer programming, ASCII (American Standard Code for Information Interchange) is a character-encoding scheme that assigns unique codes to characters, such as letters, digits, and symbols. The ASCII value of a character is a numerical representation of that character. For example, the ASCII value of 'A' is 65, 'B' is 66, and so on. In this article, we will learn how to write a simple C program to print the ASCII value of a character.

The C programming language provides a built-in feature to get the ASCII value of a character. We can use the printf() function in C to print the ASCII value of a character. The program will take a character as input from the user and then print its ASCII value.

Writing the C Program

ASCII values are used to represent characters in computers. Each character has a unique ASCII value, which is used to store and manipulate characters in computer programs. The ASCII value of a character can be obtained using the built-in functions provided by the programming language. In C, we can use the printf() function with the %d format specifier to print the ASCII value of a character.

Here is a simple C program that prints the ASCII value of a character: include int main() { char c; printf("Enter a character: "); scanf("%c", &c); printf("ASCII value of %c is %d", c, c); return 0; }. This program takes a character as input from the user, stores it in the variable c, and then prints its ASCII value using the printf() function.