Here i will post some challenge question | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Here i will post some challenge question

i found these while doing a challenge. please tell me if they are reasonable or not what is the output? int x = 0; int y = 0; for (int z = 0; z < 5; z++) { if (++x > 2 && ++y > 2) { ++x; } } System.out.println (x + y); my answer was 7. what is yours?

6th May 2017, 5:47 PM
Edward
8 Answers
+ 7
9
6th May 2017, 5:51 PM
Michael Foster
Michael Foster - avatar
+ 5
I definitely wouldn't have been able to do it in the time limit
6th May 2017, 6:00 PM
Michael Foster
Michael Foster - avatar
+ 5
The problem is that there's no time limit when you rate quizzes. That's how questions like this get approved.
6th May 2017, 6:57 PM
Michael Foster
Michael Foster - avatar
0
i see. makes sense now
6th May 2017, 5:52 PM
Edward
0
but how long did it take you to find the answer?
6th May 2017, 5:53 PM
Edward
0
yea same. so many of these long questions
6th May 2017, 6:21 PM
Edward
0
How would you do it?
6th May 2017, 6:44 PM
Kaien Yang
Kaien Yang - avatar
0
this one tricked me. i forgot java doesnt evaluate all the && conditions if the first one is false
6th May 2017, 9:10 PM
Edward