What is the output of following snippet and give reason for your answer? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the output of following snippet and give reason for your answer?

i=10; j=10; if(a<100){ if(b>50) i++; } else ++j; system.out.println("i="+i); system.out.println("j="+j);

23rd Mar 2017, 11:57 PM
Ronit Choudhury
Ronit Choudhury - avatar
4 Answers
+ 10
Yeah.. Right @krishna. I've read the code only.
24th Mar 2017, 1:15 AM
siddiq shameer
siddiq shameer - avatar
+ 7
@Kyle,@siddiq : Values of a and b are mentioned in the tags of this post. a<100 is true b>50 is true So, i = 11 after increment. Output is: i=11 j=10
24th Mar 2017, 1:12 AM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
+ 1
I don't think this will work.
24th Mar 2017, 12:47 AM
Kyle Brubacher
Kyle Brubacher - avatar
0
sir, it output will be i=21,j=20 as,a<100 is true b>50 is true and after adding i=+i ,it will be 20 and by increment it will be 21 and by adding j=+j , it will be 20
24th May 2017, 2:15 PM
Ronit Choudhury
Ronit Choudhury - avatar