+ 2

Predict the output:

int a=0; while(a<=50) for( ; ;) if(++a%50==0) break; printf("a=%d", a) ;

16th Mar 2018, 6:26 PM
Raghav Goyal
Raghav Goyal - avatar
1 Respuesta
+ 15
100 Its obvious to say , that break will occur in for loop for 1st time when value of a becomes 50 ... but the condition for while loop is still true , then for loop will only get break ... when a%50 will get equal to 0 ... & 2nd time it will become possible for a=100 & after that while loop condition also becomes false //hence , 100 will be the final value of a //hope it helps 👍
16th Mar 2018, 6:30 PM
Gaurav Agrawal
Gaurav Agrawal - avatar