How many time will the loop run?
for( int i = 19 ; i < 93 ; i++ )
{
}
The loop will run 74 times. Because in the first iteration, the counter i is initialized to 19, then the condition is checked whether 19 < 93, since the condition is true, the control enters the loop, then the counter is incremented by 1 and i now becomes 20, then the condition 20<93, since it evaluates to true, the control enters the loop again. This continues until when i is eventually incremented to 93 where the condition 93<93 becomes false and the control exits the loop. That means the loop runs from 19 to 92.
Comments
Leave a comment