C++ Program for Character to ASCII Conversion

Character to Ascii conversion

C++ program to convert a given character to its corresponding ASCII value has been shown here. The algorithm, pseudocode and time complexity of the program can be found here. Find here the flowchart of the problem.

1. C++ Program & output for Character to ASCII Conversion

Code has been copied
 C++ program for character to ASCII conversion

#include <iostream>

using namespace std;

int main() {
    //declare variables
    char x;
    int v;

    //take input of the character
    cout << "Enter the character = ";
    cin >> x;

    //convert and store ASCII value of the character
    v = (int) x;

    //print result
    cout << "\nASCII value of " << x << " is = " << v;

    return 0;


Case 1:

Enter the character = b

ASCII value of b is = 98

Case 2:

Enter the character = F

ASCII value of F is = 70

No comments:

Post a Comment

If you have any doubts or suggestions, please leave a note.