0
Write a C++ program where the user input his/her first name into an array of characters. Then display the name (from the array) one letter on each line.
3 ответов
+ 5
#include <iostream>
#include <string>
using namespace std;
int main()
{
string name;
cout << "Enter your name: ";
getline(cin, name);
for (int i = 0; i < name.length(); i++)
cout << name.at(i) << "\n";
}
Same thing, but without a 10 character limit.
+ 2
#include <iostream>
using namespace std;
int main()
{
char myName[10];
cout << "Please enter your name: ";
cin >> myName;
cout << endl;
for (int i = 0; i <= 9; i++) {
cout << myName[i] << endl;
}
return 0;
}
- 1
part2: Next display the name in the fashion of the example below. You must use for loop(s)