Answer to Question #267049 in C++ for pakie

Question #267049

How many time will the loop run?


for( int i = 4 ; i <= 20 ; i++ )  

  




1
Expert's answer
2021-11-24T00:41:25-0500
for( int i = 4 ; i <= 20 ; i++ )  

{ 


} 


when this code segmented is executed, the loop will run 17 times since in the first iteration the counter i is initialized to 4 then condition 4<=20 is checked and because the condition evaluates to true, the control enters the loop then i is incremented by 1 to become 5 and the condition 5<=20 is checked and since it evaluates to true, the control enters the loop and i keeps being incremented by 1 until when it finally becomes 21 where the condition 21<=20 which evaluates the false and the control exits the loop


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS