0

Can anyone help me with this simple task

/******************************************************************************** Question 1: Complete the Program This program intends to accept an integer N followed by N words X1, X2, ..., XN. For each word Xi (1 <= i <= N), it outputs "Hello Xi" without quotes. However, the program is incomplete. Complete the program so that it works as intended. Input Range ----------- The input to this program will only come from the following range. (Your code does not need to check if the input is in this range) 1 <= N <= 10 1 <= Xi.length() <= 20, where 1 <= i <= N Sample Run #1 ------------- N -> 3 Input -> Ali Output -> Hello Ali Input -> Bala Output -> Hello Bala Input -> Cindy Output -> Hello Cindy Sample Run #2 ------------- N -> 1 Input -> Dorothy Output -> Hello Dorothy ********************************************************************************/ #include <iostream> using namespace std; int main() { int N; cout << "N -> "; cin >> N; for (i

4th Feb 2023, 5:59 PM
Ray
Ray - avatar
3 Answers
+ 3
What have you done so far?
4th Feb 2023, 6:28 PM
JaScript
JaScript - avatar
+ 1
Ray char holds or reads only single character. C++ has string data type which can hold a string, "a series of characters ". string str; // declare string cin >> str ; // accept a word of string into str cout << str ; // output str value.. cout << " You entered " << str << endl; // to clearly see....
4th Feb 2023, 6:48 PM
Jayakrishna 🇼🇳
0
#include <iostream> using namespace std; int main() { int N; cout << "N -> "; cin >> N; char x; for (int i = 1; i <= N; ++i) { cout << "Input -> " << x; cin >> x; cout << "Output -> " << "Hello " + x; } return 0; }
4th Feb 2023, 6:32 PM
Ray
Ray - avatar