Answer to Question #307272 in C++ for Goatie

Question #307272

Wrte a C++ program that will receive your full names as strings from the screen and display every character of the string with ASCII value.








1
Expert's answer
2022-03-07T10:27:06-0500
#include <iostream>
#include <string>
using namespace std;


int main() {
    string name;

    cout << "Enter your name: ";
    getline(cin, name);
    cout << endl;

    for (int i=0; i<name.size(); i++) {
        cout << name[i] << ": " <<static_cast<int>(name[i]) << endl;
    }

    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog