# Explain this code

7/12/2020 11:32:53 AM

[email protected][email protected][email protected]®™[✓]10 Answers

New Answerif(a=8 || 1 ==5) since b =1 1==5 will return 0 (false) And since 8 is a positive integer you can assign the value 8 to a so a=8 will return true that is 1 So 1 || 0 will return 1. That is a*b will be 1*1 and a is also 1. so the final answer would be 1 1

If (a = 8 || b == 5) is evaluated as if ( a = (8 || b == 5)) lhs of || is true (8 means true value, all non-zero values evaluates to true) hence rhs is not evaluated at all. So 'a' gets the value as 1 since true is convertible to 1 so if expression is reduced to if(true) cout << a * b; // a is 1, b is 1 so output = 1 then last line prints the value of 'a' after printing the space. So your final answer is 1 1

If value of a is 8 or value of b is equal to 5 then the next line will be executed.

Aditya Pardeshi Please stop spamming in someone else thread. Delete your posts. By continuing spamming you risk your account being banned. The choice is yours. Thank you.

It will generate an error because in the third line, if(a=8||b==5), you can not use an assignment statement as a condition for if. a=8 is an assignment statement

if condition will be skipped because it return false, so it will execute cout<< " "<< a; equivalent with cout<<a; where int a=7; "" empty space. The output is 7. if condition use assignment operator == instead of = to avoid certain error in c++.

if(a=8 || 1 ==5) since b =1 1==5 will return 0 (false) And since 8 is a positive integer you can assign the value 8 to a so a=8 will return true that is 1 So 1 || 0 will return 1. That is a*b will be 1*1 and a is also 1. so the final answer would be 1 1