205k views
3 votes
What will the following program display?

#include using namespace std; int main() { int a = 0, b = 2, x = 4, y = 0;
a.cout << (a == b) << " ";
b.cout << (a != b) << " ";
c.cout << (b <=x) << " ";
d,cout << (y > a) << endl; return 0; }

1 Answer

4 votes

Answer:

0 1 1 0

Step-by-step explanation:

Running the below code

#include <iostream>

using namespace std;

int main() {

int a = 0, b = 2, x = 4, y = 0;

cout << (a == b) << " ";

cout << (a != b) << " ";

cout << (b <=x) << " ";

cout << (y > a) << endl;

return 0;

}

line 5 = states is a == b, i.e 0 == 2, which returns false 0

line 6 = states is a != b i.e 0 not equal to 2 returns true 1

line 7 = states is b <= x i.e 2 less than or equal to 4 returns true 1

line 8 = states is y >a i.e 0 > 0 returns false 0

User Damoiskii
by
4.9k points