Lets write a C program to print/display ASCII value of a user entered character.
Note: In C programming language, every alphabet, number and symbol has corresponding ASCII value(a integer number representing the character).
Data Type
char is character data type in C programming language. It stores single character information in it and has a corresponding integer value for the character, which is its ASCII value.
Source Code: C Program to Print ASCII Value of a Character
#include < stdio.h > int main() { char c; printf("Enter a character\n"); scanf("%c", &c); printf("ASCII value of %c is %d\n", c, c); return 0; }
Output 1:
Enter a character
A
ASCII value of A is 65
Output 2:
Enter a character
a
ASCII value of a is 97
Output 3:
Enter a character
1
ASCII value of 1 is 49
Output 4:
Enter a character
0
ASCII value of 0 is 48
Output 5:
Enter a character
$
ASCII value of $ is 36
Video Tutorial: C Program to Find ASCII Value of a Character
[youtube https://www.youtube.com/watch?v=XVz8n7UDVA0]
For list of all c programming interviews / viva question and answers visit: C Programming Interview / Viva Q&A List
For full C programming language free video tutorial list visit:C Programming: Beginner To Advance To Expert