C program to print ASCII value of a character

In this C program, we are going to learn how to get and print the ASCII value of a given character? This is simple C program, where we will print the ASCII code of a character.
Submitted by Manju Tomar, on November 07, 2017

Given a character and we have to find its ASCII value using C program.

What is ASCII value?

An ASCII value is a code (numeric value) of keys. We put the any character, symbol etc, than the computer can’t understand. A computer can understand only code and that code against each key is known as ASCII Code.

Read more: What is ASCII, list of ASCII codes.

In this program, we are reading two integer numbers in variable a and b and assigning the subtraction of a and b in the variable sub.

Example 1:

Enter character: a
ASCII is: 97

Example 2:

Enter character: A
ASCII is: 65


Program to get ASCII of a character in C

#include <stdio.h>

int main()
	char ch;

	//input character
	printf("Enter the character: ");

	printf("ASCII is = %d\n", ch);
	return 0;


First run:
Enter the character: a
ASCII is = 97

Second run:
Enter the character: A 
ASCII is = 65

Here, we just read a character and print it’s using %d format specifier, which is used to print an integer value. When we print the character value using %d the ASCII code prints on the screen.

Since, this is a very simple program for beginners, still you liked the program and its explanation, please share your comments.

C Basic Programs »

Related Programs


Comments and Discussions!

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.