guys How's the output is 4 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

guys How's the output is 4

int i, count =0; for(i=1;i<9;i++){ if(i%2==0) continue ; count++; } count<<count;

8th Jan 2020, 3:39 PM
Ariz imam
Ariz imam - avatar
2 Answers
+ 4
count gets incremented when i%2 != 0. So when i is 1,3,5,7 only then count++ is executed. Hence the output 4. Continue statement will transfer the control back to the beginning of the loop when i%2 == 0. So at that time count++ is not executed.
8th Jan 2020, 3:49 PM
Avinesh
Avinesh - avatar
+ 1
thanks man..
8th Jan 2020, 3:55 PM
Ariz imam
Ariz imam - avatar