printing out message n times! (continued)

I need to modify the following program so that after a correct n has been input, it prints out n times a message such as "Hello".

I am aware that I first have to make a loop that repeats until a valid number is entered by the user. Then, independent of the first loop, make a second loop that counts from 1 to N inclusive and outputs a message each time through the loop.

But I'm unsure of how I go about doing this, could someone aid me with an example if possible please?


heres my code as follows:



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

#include<iostream>
using namespace std;

int main()

{

int n;

do {

cout << "Please input a number:";
cin >> n;

if(n>=1 && n<=10) {

cout << "You have input n";
exit(1);

                   }

else {

cout << "\a";
cout << "Not in range, please input another number:";
cin >> n;

     }

while(n>=1 && n<=10)

return 0;

}

Topic archived. No new replies allowed.