ASCII value in C :
ASCII is abbreviated as the “American Standard Code for Information Interchange”. As we are humans we have our language to understand the same way machine also have the same thing to understand characters, digits, special characters that is ASCII representation of the character. It is a character encoding schema that is used for electronic communication.ASCII contains numbers, each character has its own number to represent. We have 256 character to represent in C (0 to 255) like character (a-z, A-Z), digits (0-9) and special character like !, @, # etc. This each ASCII code occupied with 7 bits in the memory. Let suppose ASCII value of character ‘C’ is 67. When we give input as ‘B’ machine treat it as 67 internally and stores its address. When we get back our original number compiler gives you 67 and other internal software converts these values into its equivalent characters.
What is ASCII code?
The full form of ASCII is the American Standard Code for information interchange. It is a character encoding scheme used for electronics communication. Each character or a special character is represented by some ASCII code, and each ascii code occupies 7 bits in memory.
In C programming language, a character variable does not contain a character value itself rather the ascii value of the character variable. The ascii value represents the character variable in numbers, and each character variable is assigned with some number range from 0 to 127. For example, the ascii value of 'A' is 65.
In the above example, we assign 'A' to the character variable whose ascii value is 65, so 65 will be stored in the character variable rather than 'A'.
Example:
We will create a program which will display the ascii value of the character variable.
#include <stdio.h>
int main()
{
char ch; // variable declaration
printf("Enter a character");
scanf("%c",&ch); // user input
printf("\n The ascii value of the ch variable is : %d", ch);
return 0;
}