Can you make if-statement with 2 thing | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can you make if-statement with 2 thing

like a = 1 and b = 2 and you want to make: if those 2 are true and if one of those is false then output comes false

7th Nov 2016, 12:45 PM
Kert Mänd
Kert Mänd - avatar
2 Answers
+ 7
if(a==1 && b==2)
7th Nov 2016, 12:55 PM
மனோஜ்குமார் பழனிச்சாமி
மனோஜ்குமார் பழனிச்சாமி - avatar
+ 2
Logical operators. == = equals < = less than <= = less than or equal > = greater than >= = greater than or equal && = and || = or You can use all these how you want. a = 1; b = 2; if(a == 1 && b == 2) // true true. true condition if(a == 1 || b == 8) // true false. True condition if((a == 1 && b == 4) || b == 2) // false true. True condition if(a == 1 && b == 3) // true false. False condition.
8th Nov 2016, 7:26 AM
Andreas BeEm Kvist
Andreas BeEm Kvist - avatar