ASCII Value
ASCII Value in C
To find the ASCII value of a character in C, you can use the int
data type and the %d
format specifier in the printf
function. Here's an example:
#include <stdio.h>
int main() {
char ch = 'A';
int asciiValue = ch;
printf("The ASCII value of %c is %d\n", ch, asciiValue);
return 0;
}
In this example, the character 'A'
is assigned to the variable ch
. The ASCII value of 'A'
is then assigned to the variable asciiValue
. Finally, the printf
function is used to display the character and its corresponding ASCII value.
The output of this program will be:
The ASCII value of A is 65
The ASCII value of a character is determined by its position in the ASCII table. For example, the ASCII value of 'A'
is 65, 'B'
is 66, and so on.
Please let me know if you need further assistance!