| |
|
ASCII Value C
ASCII full form is American Standard Code for Information Interchange. It is a character encoding scheme which is basically used for electronics communication. Here each character or special character is represented by some ASCII code and here each ascii code will occupies 7 bits in memory.
When we say about C programming language a character variable does not contain a character value of itself rather the asciii value of the character variable. ASCII value represents the character variable in numbers, and each character variable is assigned with some number range from 0 to 127. To understand this a example of ascii value of "A" is 65.
ASCII value of "A" is 65 so 65 will be stored in the character variable rather than "A".
Example for ASCII Character Input and Output
In above example program will display ascii value of the charcter variable that we have input in the screen. First user will give the character input then values of that value get stored in the "ch" variable. Then after that it will print value of "ch" variable by using %c format specifier and it will display "A" because we have given the charcter input as "A". If we use %d as format specifier then ascii value will be displayed as 65.
Output
Enter a characterA
The ascii value of the ch variable is : 65
Example for ASCII Character from 0-255 value of all characters
In above program this will print ascii value of all characters from 0 to 255 through the for loop.
Example for ASCII Character for Given input
In above code we will take input from user and then convert all character from input to ASCII values. And this will also provide the sum of all character of string in "sum" variable. | |
|
|
|
|