Source Code:
  1. //Wite a C program to print the ASCII value of any charater. 
  2. #include <stdio.h>
  3. #include<conio.h>
  4. int main()
  5. {
  6.     char c;
  7.     printf("Enter a character: ");

  8.     // Reads character input from the user
  9.     scanf("%c", &c);  
  10.     
  11.     // %d displays the integer value of a character
  12.     // %c displays the actual character
  13.     printf("ASCII value of %c = %d", c, c);
  14.     
  15.     getch();
  16. }


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