This C++ program is used to find and print the ASCII value of a letters, numbers, and other characters.



Each character or number has its own ASCII value.

Example:

The ASCII value of the number '5' is 53 and for the letter 'A' is 65.

Example:

/* 
* File: ascii.cpp
* Author: Gautam
* Created on August 17, 2017, 4:00 PM
*/ 

#include <iostream>
using namespace std;

int main(){
        char c = 'w';
        cout << "ASCII value of " <<c<< " is " <<(int)c<<endl;
        return 0;
}

Program Output:

ASCII value of w is 119

Example:

/* 
* File: ascii.cpp
* Author: Gautam
* Created on August 17, 2017, 4:00 PM
*/ 

#include <iostream>
using namespace std;

int main(){
        char c;
        cout << "Please enter a character: "; cin >> c;
        cout << "ASCII value of "<<c<<" is "<<(int)c<<endl;
        return 0;
}

Program Output:

Please enter a character: G
ASCII value of G is 71


Found This Page Useful? Share It!
Get the Latest Tutorials and Updates
Join us on Telegram