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.
#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;
}
Comments
Leave a comment