C Program to Print ASCII Value of a Character


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

  1. #include < stdio.h >  
  2.   
  3. int main()  
  4. {  
  5.     char c;  
  6.   
  7.     printf("Enter a character\n");  
  8.     scanf("%c", &c);  
  9.   
  10.     printf("ASCII value of %c is %d\n", c, c);  
  11.   
  12.     return 0;  
  13. }  

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 Link: https://www.youtube.com/watch?v=XVz8n7UDVA0 [Watch the Video In Full Screen.]

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

Leave a Reply

Your email address will not be published. Required fields are marked *