Source Code:
- //Wite a C program to print the ASCII value of any charater.
- #include <stdio.h>
- #include<conio.h>
- int main()
- {
- char c;
- printf("Enter a character: ");
- // Reads character input from the user
- scanf("%c", &c);
- // %d displays the integer value of a character
- // %c displays the actual character
- printf("ASCII value of %c = %d", c, c);
- getch();
- }
Output:
1.Enter a character: a
ASCII value of a = 97
2.Enter a character: Z
ASCII value of Z = 90
0 comments:
Post a Comment