lets say i had this

int times

cout<<"enter times you want to repeat";

cout<<"Hello what age are you?";


how would i get it to repeat this section of codes the same amount as the user inputs?

but make it that if he input repeat by 5 times, that each time you input an age, for the 5 times, that that age is make into a variable.


so if you click repeat 3 times and typed in 4,6 and 8
that they would be each seprate varibles and be able to be used in further code

also we can not use arrays.
for loops we can only use
for,while,do while loops
among other basic things, but not arrays yet
we can also use if, else, else if

Edited by Reverend Jim: Fixed formatting

7 Years
Discussion Span
Last Post by zendet

Use a for loop that ranges from 1 to the number input by the user.

int times;
for(int i = 1; i <= times; i++)
//do actions
}//close for loop

Hopefully this can help you get started.

Edited by Grn Xtrm: n/a


thanks but lets say he enters a different number for each of the repeats, how do i make sure they are saved spearatly?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.