We all know && (double and) for and condition.
for single and What happen internally how condition gets executed.
if(true & bSuccess)
{
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
in this expression both operands are promoted to
intand then&is evaluated. If bSuccess is true you will get1 & 1which is1(ortrue). If bSuccess is false you’ll get1 & 0which is0(orfalse)So, in case of boolean values
&&and&will always yield the same result, but they are not totally equivalent in that&will always evaluate both its arguments and&&will not evaluate its second argument if the first one is false.Example: