C program to print ASCII value of character:
In computers a character holds a integer value for it instead of the character, i.e. called ASCII value.
For Example: ASCII Value of character "A" is 65.
Like wise the number between  0 to 127  is used for every character in computer.
Here we will see the C program which will return the ASCII code of any character that we will enter.
#Example:
  #include <stdio.h>
  void main()
  {
     char ascVal;
     printf("Enter a character: ");
     scanf("%c",&ascVal);
     //%c prints actual character 
     //%d prints integer value of the character i.e. ASCII value of character.
     printf("ASCII value for character %c is %d.",ascVal,ascVal);
  }
Output:
Enter a character: A ASCII value for character A is 65.

 
 
 
 
 
0 comments:
Post a Comment