+ 5
What is the output of this code segment ?
cout<<(3&&4); Please explain how (a&&b) works...
2 Answers
+ 3
The && operator checks whether all of its logical comparisons are true. In this case, you are asking whether 3 AND 4 are true. In C++, any value that is greater than zero is evaluated as true. So, you could write the following:
cout << (3 && 5 && 9 && 21 && 2) << endl;
//This will output 1
In C++, the value of 'true' is outputted as 1 and 'false' is outputted as 0.
cout << (3 && 4 && 0) << endl;
//This will output 0.
+ 6
@Zeke Thanks..!
Really a helpful answer