Online visitors

People learning around the world

Online

—

Visitors exploring W3Schools

Online visitors by country Circles show approximate country locations. The country list provides the visitor counts.

Circles represent countries, not exact visitor locations.

Country

Online

Loading country activity…

    C++ Program to Find ASCII Value of a Character

    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

    Notifications

    Updates are enabled for this browser.

    Receive new tutorials, articles and learning resources. You can turn updates off anytime.