What is the difference between & and && ?
& is bitwise operator. && is logical operator.
& evaluates both sides of the operation.
&& evaluates the left side of the operation, if it's true, it continues and evaluates the right side.
all are correct.
& is a bitwise operator, which is used to perform Bitwise AND operator on the binary bits on both the sides of this operator.
Generally & operation will be used to perform bit level operations like enabling or disabling some flags.
&& is a logical operator which checks if expressions on both the sides of this operator yields true.
&& operator works from left hand side. If any of the expression returns false, then this logical operation will be stopped and exited. (Will not proceed further).
Back To Top