Subscribe Us

How to get ASCII value of Char in C programming - c exercise - smartduniya

What is ASCII ?

The complete ASCII form is the American Standard Code for data exchange. It is a character encoding scheme used for electronic communication. Each character or a particular character is represented by some ASCII code.
In the C programming language, a character variable does not contain a character value by itself, but the character variable has an ASCII value.
You know that every character has a different ASCII value . Even a capital letter and small letter has different ASCII value .
The character ASCII value range is 0 to 127.

Example : character ‘ A ‘ , it’s ASCII value is 65.
In this post you will learn ,


How to get ASCII value of any charecter in c ?


To find the ASCII value of a character you will learn in this C program,
the user asked to enter any character and this program will display the ASCII value of that character.
An Ex. user give the input 'A' and we all know the ASCII value is 65.
This ASCII value will display on the screen.
Let's Go to the code


Note :Click on the button to copy the text from the text field. Try to paste the text (e.g. ctrl+v) afterwards in a different window, to see the effect.

In this C program to find the ASCII value of a
character , the first printf statement will ask the user to enter a character. After that, the character
assigned to the variable ch . The 2nd printf statement,
we are only displaying the output value but we have used " % d "format stream instead of using "% C".
This is why it shows the value of the integer (I mean the ASCII value of this charecter).

OutPut :

Hope you understand if you face any problem comment below ,will try to help you.

 

Don’t forget to Subscribe our Blog to get update. Just put your email on subscribe box and hit subscribe button , next verify your email , it will be done.

You will get every single post when we will upload in Smartduniya.


Also learn this post :


How to write comment in C ?

How to write keyword, identifires in C ?

How to write Printf() function in C ?

Post a Comment

0 Comments