hi guys i am a beginner at programming, what does the first line of this code does?....i know the second line generates a random number between 0 and 10 but i am not sure what the first line does....please explain

for(int index=5; index<10; index++)
{random_integer = (rand()%10)+1 }

Recommended Answers

It runs what is in braces (i.e. the second line) with the variable index set to 5, then increments index to 6, runs the second line again, then 7, then 8, and then 9, all the same ... and then when it increments index to 10, we stop, because it …

Jump to Post

All 2 Replies

It runs what is in braces (i.e. the second line) with the variable index set to 5, then increments index to 6, runs the second line again, then 7, then 8, and then 9, all the same ... and then when it increments index to 10, we stop, because it says to only do it while index is less than 10.

Be a part of the DaniWeb community

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