What is the output of the following code? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

What is the output of the following code?

I can not figure out the output of this question, can anyone help? ------------------------------------------------------------------------------ What is the output of the following code? int a = 11; int b = 12; int c = 40; if (a > 100 || b > 3) { System.out.println(a); } else { System.out.println(c); }

16th Jan 2019, 10:17 PM
Collin
4 Answers
+ 7
int a =11,b =12,c =40; //● false OR true evaluates to true, so if() block will execute. //● if any of conditions separated by OR returns true then whole condition evaluates to true if (a>100 || b>3) { System.out.println(a); //● prints 11 } else { System.out.println(c); }
17th Jan 2019, 2:14 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 5
|| = Or && = and at last output is 11 . //System.out.println(a);
17th Jan 2019, 2:42 AM
[SE]شبگرد
[SE]شبگرد - avatar
+ 1
Try using code playground. Paste this code and run it and you will see result
16th Jan 2019, 10:24 PM
Elva
Elva - avatar
0
La salida es 11 // este operador (||) ejecuta cualquier a de las dos condiciones, siempre y cuando una de las dos sean verdadero. ( a> 100 || b> 3) esto quiere decir que si (a) es mayor a (11) entonces imprimir (11) sino, imprimir (b) siempre y cuando (b) sea mayor a (3) (a) no es mayor 100// y (b) si es mayor a 3 // pero hay una trampita.. no esta el// System.out.println(b); // pero si esta System.out.println(c);
7th Mar 2019, 4:36 AM
Caio Zacarias
Caio Zacarias - avatar