Repeating the output

Hey guys

How do you keep repeating the output line after the user inputs the information

Thanks
closed account (S6k9GNh0)
Please explain more...I'm not sure what your talking about.
sorry

What I meant was if say for example cout was "insert number" then once the user inputs a number, cout << "insert number" will appear on the next line, etc in order for the user to input another numberon the fourth line.

e.g.

Insert number
5
Insert number

etc
Wizard, this is quite a basic question and please dont take offence to this but, I wouldn't advise you to create programs that are outside the scope of your ability. If you haven't learnt it yet, wait until you do otherwise you run the risk of using it incorrectly and then having to re-learn it. And neither of us want your time wasted :)
look at a while loop or a do while loop
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
using namespace std;

int main() {
    int x(0);
    int y(0);
    int number(0);
    cout << "how many times would you like to enter a number? ";
    cin >> y;
    while ( x < y ) {
		cout << "enter number:";
		cin >> number;
		cout << "the number you entered was " << number << endl;
		x++;
    }
    cout << "done. press ENTER";
    cin.get();
    cin.get();
    return 0;
}


something like this?
Last edited on
Topic archived. No new replies allowed.