/* */ Click to Join Live Class with Shankar sir Call 9798158723

find an ASCII value of an alphabet in C ?


Q.) find an ASCII value of an alphabet in C ?
 #include<stdio.h>
 #include<conio.h>
 void main()
 {
 char c;
 printf("Enter a character: ");
 scanf("%c",&c);   /* Takes a character from user */ 
 printf("ASCII value of %c = %d",c,c);	
 getch();
 }
Output
Enter a character: h    /* say c = h */.
ASCII value of h = 104

Program Explanation


Step 1: Include header files (#include<stdio.h> and #include<conio.h>).

Step 2: Start with main function with return type.

Step 3: parenthesis to start and end the program { }.

Step 4: declare the variables with data types. i.e, 'c' is a character so we declare 'c' variable with "char" data type.

Step 5: Use output function printf() to print the output on the screen.

Step 6: use input function scanf() to get input from the user.

Step 7: using getch() function to hold the screen.