on Leave a Comment

C++ Program to Find ASCII Value of a Character

This article contains C++ Program to Find ASCII Value of a Character.

ASCII stands for American Standard Code for Information Interchange. ASCII code is 7 bit code. ASCII code is used to represent text in computers, and other devices.

C++ Program to Find ASCII Value of a Character

#include <iostream>
using namespace std;
int main()
{
    char ch;
    for(int i=1;i<255;i++)
    {
        ch=i;
        cout<<i<<" -> "<<ch<<endl;
    }
    return 0;
}

OUTPUT:


C++ Program to Find ASCII Value of a Character



C++ Program to Find ASCII Value of Particular Character

#include <iostream>
using namespace std;
int main()
{
       char c;
       cout << "Enter a character : ";
       cin >> c;
       int x=int(c);
       cout << "ASCII Value of " << c << " is " <<x;
       return 0;
}

OUTPUT:

Enter a character : b
ASCII Value of b is 98


0 comments:

Post a Comment