lets say i had this

int times


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



---->  
cout<<"Hello what age are you?";
cin>>age;

  <-------

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.

example

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

Recommended Answers

All 2 Replies

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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.