sum=0; for(int i=1; i<10; i+=2) if 10/i==2 break; sum+=I cout<<sum | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

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 :)

8th Sep 2016, 6:05 PM
saujanya verma
saujanya verma - avatar
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
8th Sep 2016, 6:29 PM
Zen
Zen - avatar
0
explain better please
5th Dec 2020, 7:52 PM
Gustave A C/D C ☢️ 🛸♨️🛸🛸