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

2 Answers

+ 7

if(a==1 && b==2)

+ 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.