Computer Science, asked by pv7153021, 5 months ago

what is AND operator (&&)?

Answers

Answered by mohtasemanaaz
1

Answer:

The logical AND operator && is a binary operator and is used to combine two conditions or expressions. The resultant value is boolean value. The result is true if both the value are true, and the result is false if either the value is false

Answered by iamswetankp3zlz3
0

Answer:

let's assume 1 is true and 0 is false (which is also true for binary number system)

according to defination of and (&&) operator, if both LHS and RHS of && are true then we will get true.

True && True = True

True && False = False

you get it, 'this' and 'that' has to be true to get true, if any of them or both of them are false you simply get false.

use case:

if I told you to answer if a given number is odd or even, you will simply try to divide it by 2 to check if it's is completely divisible or not, if not and you get 1 as a remainder then you will say it's an odd number.

let's take 13 which is an odd number and it's binary representation is 1101. if you and (&&) it with 1 (binary 0001) you will get 1, in case of an even number you will get a zero (0).

So inside your mobile or computer processor this is the way they do it. Faster than dividing it by 2 and checking for remainder.

if you want to learn more use cases of binary operators, search for "bit manipulation".

Similar questions