New course! Every coder should learn Generative AI!
Try a free lesson0
sum=0; for(int i=1; i<10; i+=2) if 10/i==2 break; sum+=I cout<<sum
I'm having trouble with these types of questions (the incrementing types) can someone explain a step by step to me? thanks :)
2 Answers
+ 4
I'm assuming brackets before if and after sum+=1;.
First loop: i=1, sum becomes 1
Second loop: i=3, sum becomes 2
Third loop: i=5, 10/5 is 2 so the loop is broken
sum is printed: 2
0
explain better please