0

int res=0; for(int i=1;i<10;i+=3) { if(10/i==2) continue; res += i; } cout<<res<<endl;

Why is output 8 ???

22nd May 2020, 2:38 PM
Karan Dewangan
Karan Dewangan - avatar
1 Answer
+ 1
The i's provided by the loop conditions are 1, 4 and 7. 10/4 (int division) is 2, so that step is left out by continue. So only 1 and 7 are added to res. Result: 8
22nd May 2020, 2:41 PM
HonFu
HonFu - avatar