It is possible to combine boolean expressions with a comma separator. I have seen it in a code and i am not sure what this resolves to. I wrote some sample code.
int BoolStatement(void)
{
using std::cout;
using std::endl;
cout << "(0, 0) => " << (0, 0) << endl;
cout << "(0, 1) => " << (0, 1) << endl;
cout << "(1, 0) => " << (1, 0) << endl;
cout << "(1, 1) => " << (1, 1) << endl;
cout << "(0, 0) => " << (0, 0) << endl;
cout << "(0, 3) => " << (0, 3) << endl;
cout << "(5, 0) => " << (5, 0) << endl;
cout << "(7, 1) => " << (7, 1) << endl;
cout << endl;
return 0;
}
The output of this is:
(0, 0) => 0
(0, 1) => 1
(1, 0) => 0
(1, 1) => 1
(0, 0) => 0
(0, 3) => 3
(5, 0) => 0
(7, 1) => 1
I am not sure if that is only true for my system and if this call is actually the same as a boolean combination of statements.
What is the output, is it the same on all systems? Why is that statement possible and is there documentation on it?
It is used to display the output to the standard output device i.e. monitor. It is associated with the standard C output stream stdout. The data needed to be displayed on the screen is inserted in the standard output stream (cout) using the insertion operator(<<).
The "c" in cout refers to "character" and "out" means "output". Hence cout means "character output".
<< have two meaning one is left shift operator used in most of programming language which shift the bit left in specified number of time. and other << is use C++ for output insertion operator with cout object this mechanism called operator overloading in C++.
From the instruction the output put of the program is 10. Hence option 'a' is correct.
The comma operator returns the righthand side.
Wikipedia:
In the C and C++ programming languages, the comma operator (represented by the token ,) is a binary operator that evaluates its first operand and discards the result, and then evaluates the second operand and returns this value (and type).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With