Monday, 2 March 2015

C++ program to print ASCII value of a character

Problem:- Write A Program To Find ASCII Value Of Any Character or C++ program to print ASCII value of a character or C program to print ASCII value of a character

ASCII:- Abbreviated from American Standard Code for Information Interchange, is a character encoding standard for electronic communication. ASCII codes represent text in computers, telecommunications equipment, and other devices. Most modern character-encoding schemes are based on ASCII, although they support many additional characters. 

ASCII-code order is also called ASCIIbetical order.The main deviations in ASCII order are:

1. All upper case come before lowercase letters; for example, "Z" precedes "a".

2. Digits and many punctuation marks come before letters.

ASCII Value Chart Is Below 

ASCII Value Chart


Logic:- As we know that  every key in keyboard has a unique ASCII key, so for as you enter or press any key on keyboard we take string and convert string into integer value, or we can also take a string and print the string ASCII value using loop as you see in the below program. In this program, i am taking a character or string and by using loop convert the string into integer, actually string in not converting it just printing an integer value of that character and the loop is running until our string not finished that's why we use '\0' means end of string or we can say that last character in string.


 for(i=0; str[i]!='\0'; i++)
 cout<<(int)ch<<" ";

as you can see that each character of the string array is storing in character and print the character ASCII value.

Explanation:-  ASCII Full Form " American Standard Code for Information Interchange ". Every Character of your Keyboard Have It's Own Unique Number Like 

ASCII value for small character ' a ' to ' z ' is ' 97 ' to ' 122 '.
ASCII value for capital character ' A ' to ' Z ' is ' 65 ' to ' 90 '.
ASCII value for number ' 0 ' to ' 1 ' is ' 48 ' to ' 57 '  etc.


using namespace std;
int main()
 string str;
 int i;
 char ch;

 cout<<"Enter String Or Character For ASCII Value \n";

 cout<<"\nString Is Given Below\n";

 cout<<"\n\nASCII Value Of Given String Or Character Is Below\n\n";

 for(i=0; str[i]!='\0'; i++)
 cout<<(int)ch<<" ";

  return 0;



C++ program to print ASCII value of a character

You May Like This:-

1. C++ Program To Check Character Is Uppercase, Lowercase Alphabet Or A Digit Or A Special Symbol

2. Java Program To Find Area Of Triangle

3. C++ Program For Calculate Simple Interest

4. C++ Program For Find The Gross Salary Of An Employee

5. C++ Program For Calculate Percentage Of 5 Subjects

6. Java Program For Converting Temperature Celsius Into Fahrenheit

7. C Program To Find Character Is Vowel Or Not

8. Hacker Rank Solution Program In C++ For " StringStream "

9. Hacker Rank Solution Program In C++ For " Attribute Parser "

10. Geeksforgeeks Solution For " Reverse Coding "

Ghanendra Yadav
Ghanendra Yadav

I Am Ghanendra Yadav Owner Of This Website. I Love Programming, Web Developing, Logo Making, Banner And Website designing. Currently I Am Studying In NIT Warangal And Also Working With WSDC( As Web Application Developer ) In NIT Warangal For Any Query Mail Me I Will Answer Within 24 Hours Email:-

Find me on Social Media

Facebook | Twitter | Google+ | RSS Feed

No comments:

Post a Comment