Monday, 2 March 2015

C++ Program To Find ASCII Value Of Any Character Or String

Problem :- Write A Program To Find ASCII Value Of Any Character

Explanation :-  ASCII Full Form " American Standard Code for Information Interchange " .
Every Character of your Keyboard Have It's Own Unique Number Like 
ASCII value Of Small 'a' to 'z' is '97' to '122'
ASCII value Of Small 'A' to 'Z' is '65' to '90'
ASCII value Of Small '0' to '1' is '48' to '57'

ASCII Value Chart Is Below 

ASCII Value Chart
Image Source Wikipedia

Solution :-

#include<bits/stdc++.h>
using namespace std;
int main()
{
string str;
int i;
char ch;

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

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

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

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

cout<<endl;
  return 0;

}

Output:-

C++ Program To Find ASCII Value Of Any Character Or String

No comments:
Write comments

Recommended Posts × +