wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

C++ Operators

Total questions: 20

Worksheet time: 12mins

Name
Class
Date
1.

What will be the output of the following code?

int x = 12, y=12;

cout << (x <= y) << endl;

a)

0

b)

1

c)

true

d)

false

2.

What will be the output of the following code?

int x = 2;

cout << x++ << endl;

a)

2

b)

3

c)

Compilation Error

d)

Compiler dependent output

3.

What will be the output of the following code?

int x = 2;

cout << --x << endl;

a)

1

b)

2

c)

Compilation Error

d)

Compiler dependent output

4.

What will be the output of the following code?

int x = 4+5*7-6%2/2;

    cout << x;

a)

39

b)

0

c)

38

d)

40

5.

What will be the output of the following code?

cout << (5<7 && 7>3) << endl;

a)

0

b)

1

c)

true

d)

false

6.

What will be the output of the following code?

int x=5, y=6, z=7;

cout << (x>y && ++y) << endl;

cout << y << endl;

a)

0

6

b)

1

7

c)

1

6

d)

0

7

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;

a)

0

6

b)

1

7

c)

1

6

d)

0

7

8.

What will be the output of the following code?

int y = 5;

    int x = y = y + 5;

    cout << x << " " << y << endl;

a)

10 10

b)

10 5

c)

compilation error

d)

5 5

9.

What will be the output of the following code?

int y;

    y = 1,2,3;

    cout << y << endl;

a)

1

b)

2

c)

compilation error

d)

3

10.

What will be the output of the following code?

int y = -20;

    cout << !y << endl;

a)

1

b)

2

c)

compilation error

d)

3

11.

What will be the output of the following code?

int x = 25, y = 35;

    cout << (x && y) << endl;

a)

1

b)

0

c)

compilation error

d)

true

12.

What will be the output of the following code?

int x = -1, y = 3;

    cout << (x && y) << endl;

a)

1

b)

0

c)

compilation error

d)

true

13.

What will be the output of the following code?

int x = 0, y = 3;

    cout << (x && y) << endl;

a)

1

b)

0

c)

compilation error

d)

true

14.

What will be the output of the following code?

cout << !(3 && 0) << endl;

a)

1

b)

0

c)

compilation error

d)

false

15.

What will be the output of the following code?

int x = 5, y = 10;

cout << (x & y);

a)

0

b)

15

c)

5

d)

1

16.

What will be the output of the following code?

int x = 5, y = 10;

cout << (x | y);

a)

0

b)

15

c)

5

d)

1

17.

What will be the output of the following code?

int x = 5, y = 10;

cout << (x ^ y);

a)

0

b)

15

c)

5

d)

1

18.

What will be the output of the following code?

int x = 10;

cout << ~x;

a)

5

b)

01

c)

-11

d)

-10

19.

What will be the output of the following code?

int x = 5, y = 10;

    x = x << 1;

    y = y >> 1;

    cout << x << " " << y;

a)

1 0

b)

5 10

c)

10 5

d)

Compilation Error

20.

What will be the output of the following code?

int y;

    y = (1,2,3);

    cout << y << endl;

a)

1

b)

2

c)

compilation error

d)

3