Write a C program to accept a character from user and display its ASCII value. ASCII stands for American Standard Code for Information Interchange. ASCII codes represent text in computer. So, let’s start to develop our program.
Output will be look like this:
Enter any character to find it’s
ASCII code: A
ASCII code of ‘A’ is ‘65’.
Program :
/* Author: CodeTryCatch * C program to find ASCII value of a character */ #include<stdio.h> void main() { char alpha; printf("Enter any character to find it's ASCII code: "); scanf("%c",&alpha); printf("\nOutput :\n\n"); printf("ASCII code of '%c' is '%d'.\n\n",alpha,alpha); }
Step by step descriptive logic of a program.
Step 1 : First we have to declare one variable of character type to accept input from user.
Step 2 : To print ASCII value of entered character here we used %d format specifier. Because, ASCII code returns integer values and to print integer values we used %d as a format specifier.
Step 3 : Here, we can accept any character like alphabets, numbers or any special characters it will show it’s ASCII code.
Output :
Keep coding...
Thanks for visiting….😊
0 Comments
If you have any doubts, please mention in comment or if you want to discuss privately then please use this email : codetrycatch@gmail.com.
We will definitely try to contact you. Thanks.