Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need help with the following question. I just needed some opinions about which

ID: 3726821 • Letter: I

Question

I need help with the following question. I just needed some opinions about which would be the right answer although I know the answer, I am really not certain about it.

Circle all of the following for loops which will cause the body of the loop to be executed exactly 10 times.

            a) for(int i = 0; i <= 10; i++)

     b) for(int i = 1; i < 10; i++)

     c) for(int i = 2; i <= 11; i++)

     d) for(int i = 2; i < 12; i++)

     e) none of these for loops will execute the loop 10 times

Explanation / Answer

Answer : (c), (d)

The first loop would run 11 times as i goes from 0 to 10.

The second loop would run 9 times as i goes from 1 to 9.

The third loop would run 10 times as i goes from 2 to 11.

The fourth loop would run 10 times as i goes from 2 to 11.