Its an assignment that ive been stuck on for a day, please help.
Create a C++ program that generates the following display based on user input:
Output should display:
Enter # of times to display:¨3
Hello Hello Hello
b. Use a loop .
c. Important: for every five items displayed, skip a line in your display:
Output should display:
Enter # of times to display:¨12
Hello Hello Hello Hello Hello
Hello Hello Hello Hello Hello
Hello Hello
Its an assignment that ive been stuck on for a day, please help.
You've been stuck on this for a day with 0 progress? Surely you must have done something. Please show us what you got so far, use code tags for the code - http://www.cplusplus.com/articles/jEywvCM9/
#include <iostream>
usingnamespace std;
int main() {
unsigned n, i = 1, counter = 0; // create a counter
cout << "Enter # of times to display: ";
cin >> n;
do
{
cout << "Hello ";
i++;
counter++; // increment it each iteration
if (counter == 5){ // once it hits 5, you've printed out 5 hello's
cout << "\n"; // make a new line
counter = 0; // put it back to 0 so you can count to 5 again
}
} while (i <= n);
return(0);
}