need examples

...cant fully understand looping,, kindly give an example please..
the one with... the program ask to enter an number repeatedly until it reach a certain point...
tnx.. super..super,,
If you don't understand how loops work, read the tutorial: http://www.cplusplus.com/doc/tutorial/control/
btw, I think you need a while loop.
like this?
1
2
3
4
5
6
7
8
9
int input = 0;
int nInput = 0;
while (nInput <= 100) {
   std::cout << "enter a number: ";
   std::cin >> input;
   nInput += input;
}

std::cout << "your number went over 100" << std::endl;


theres also a for statement
1
2
3
4
5
6
7
int input = 0;
for (int i = 0; i <= 100; i += input) {
   std::cout << "enter a number: ";
   std::cin >> input;
}

std::cout << "your number went over 100" << std::endl;


Last edited on
Topic archived. No new replies allowed.