NEW
Font size
WorksheetsC++ Operators
Total questions: 20
Worksheet time: 12mins
What will be the output of the following code?
int x = 12, y=12;
cout << (x <= y) << endl;
0
1
true
false
What will be the output of the following code?
int x = 2;
cout << x++ << endl;
2
3
Compilation Error
Compiler dependent output
What will be the output of the following code?
int x = 2;
cout << --x << endl;
1
2
Compilation Error
Compiler dependent output
What will be the output of the following code?
int x = 4+5*7-6%2/2;
cout << x;
39
0
38
40
What will be the output of the following code?
cout << (5<7 && 7>3) << endl;
0
1
true
false
What will be the output of the following code?
int x=5, y=6, z=7;
cout << (x>y && ++y) << endl;
cout << y << endl;
0
6
1
7
1
6
0
7
What will be the output of the following code?
int x=5, y=6, z=7;
cout << (x<y || ++y) << endl;
cout << y << endl;
0
6
1
7
1
6
0
7
What will be the output of the following code?
int y = 5;
int x = y = y + 5;
cout << x << " " << y << endl;
10 10
10 5
compilation error
5 5
What will be the output of the following code?
int y;
y = 1,2,3;
cout << y << endl;
1
2
compilation error
3
What will be the output of the following code?
int y = -20;
cout << !y << endl;
1
2
compilation error
3
What will be the output of the following code?
int x = 25, y = 35;
cout << (x && y) << endl;
1
0
compilation error
true
What will be the output of the following code?
int x = -1, y = 3;
cout << (x && y) << endl;
1
0
compilation error
true
What will be the output of the following code?
int x = 0, y = 3;
cout << (x && y) << endl;
1
0
compilation error
true
What will be the output of the following code?
cout << !(3 && 0) << endl;
1
0
compilation error
false
What will be the output of the following code?
int x = 5, y = 10;
cout << (x & y);
0
15
5
1
What will be the output of the following code?
int x = 5, y = 10;
cout << (x | y);
0
15
5
1
What will be the output of the following code?
int x = 5, y = 10;
cout << (x ^ y);
0
15
5
1
What will be the output of the following code?
int x = 10;
cout << ~x;
5
01
-11
-10
What will be the output of the following code?
int x = 5, y = 10;
x = x << 1;
y = y >> 1;
cout << x << " " << y;
1 0
5 10
10 5
Compilation Error
What will be the output of the following code?
int y;
y = (1,2,3);
cout << y << endl;
1
2
compilation error
3
