wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Toán tử trong C ++

Total questions: 20

Worksheet time: 17mins

Name
Class
Date
1.

This code will output 0.

cout<< 23 % 2 <<endl;

a)

True

b)

False

2.

Which of these operators increments an integer variable by one?

a)

**

b)

++

c)

--

d)

$$

3.

Upon execution, what is stored in variable P?

P = 14 - 6 * 2;

a)

16

b)

2

c)

22

d)

26

4.

What should be the values of variable b and variable h to get the value of area equals to 75 where area = 0.5 * b * h;

a)

b = 10

h = 10

b)

b = 15

h = 15

c)

b = 10

h = 15

d)

b = 20

h = 10

5.

What is the output of the given statement?

P = 20 + 4 – 50 % 6;

a)

22

b)

26

c)

2

d)

12

6.

Which of the following is an example of arithmetic operators in C++ programming?

a)

&&

b)

||

c)

%

d)

$$

7.

Which of the following statements is TRUE about logical And (&&) operator?

a)

The output is 1 only when anyone of the values is 0.

b)

The output is 1 only when all values are 0.

c)

The output is 1 only when anyone of the values is 1.

d)

The output is 1 only when all values are 1.

8.

If A = 1, B = 0 and C = 1 then what is stored in W?

W = !(A && B || C);

a)

1

b)

0

c)

-1

d)

Error

9.

If A = 0, B = 1 and C = 1 then what is stored in W?

W = (A || B && C);

a)

0

b)

1

c)

-1

d)

Error

10.

Consider the given code. What is the value of y upon execution?

int Y = 5;

Y++;

Y++;

cout<<Y*2;

a)

5

b)

10

c)

7

d)

14

11.

Consider the given code. What is the value of y upon execution?

int D = 5;

D--;

D--;

cout<<D+4;

a)

3

b)

7

c)

9

d)

11

12.

The expression A += B; is equivalent to

a)

A + B = B;

b)

A + A = B;

c)

B + A = A;

d)

A = A + B;

13.

The logical operation for which this table is shown is

a)

AND operation.

b)

NOT operation.

c)

OR operation.

14.

Which of the following is an example of a relation operator?

a)

!

b)

!=

c)

++

d)

||

15.

If A = 5, B = 10, then which expression will output True(1)?

a)

cout << (A > B);

b)

cout << (A >= B);

c)

cout << (A < B);

d)

cout << (A == B);

16.

If W = 20, Y = 15, then which expression will output False(0)?

a)

cout << (W != Y);

b)

cout << (W < Y);

c)

cout << (W <= Y);

d)

cout << (W == Y);

17.

What should be the values of A and B so that the statement cout<< (A < B); becomes True(1)?

a)

A = 2 and B = 2

b)

A = 2 and B = 3

c)

A = 3 and B = 2

d)

A = 3 and B = 3

18.

What should be the values of P and Q so that the statement cout<< (P > Q); becomes True(1)?

a)

P = 4 and Q = 3

b)

P = 3 and Q = 3

c)

P = 4 and Q = 4

d)

P = 4 and Q = 3

19.

Consider the given expression.

(x && y) || (y && z)

The expression evaluates TRUE (1) when the values of x, y and z are

a)

x = 0, y = 1 and z = 0.

b)

x = 1, y = 0 and z = 0.

c)

x = 0, y = 1 and z = 1.

d)

x = 1, y = 0 and z = 1.

20.

The expression that contains two relational operators is

a)

(x + y) <= (y + z)

b)

(x == y) && (y != z)

c)

(x && y) || (y && z)

d)

(++x / --y) >= (++y / --z)