C++ Operators

C++ Operators

Professional Development

20 Qs

quiz-placeholder

Similar activities

Torno (parte 1)

Torno (parte 1)

Professional Development

20 Qs

Actividad #1 Taller de Compras

Actividad #1 Taller de Compras

Professional Development

15 Qs

Quiz diciembre 2020 Territorio Levante

Quiz diciembre 2020 Territorio Levante

Professional Development

17 Qs

TEORIA GENERAL DE SISTEMAS - 2502630

TEORIA GENERAL DE SISTEMAS - 2502630

Professional Development

20 Qs

pre new part management knowledge

pre new part management knowledge

Professional Development

20 Qs

Dosimetría de la radiación

Dosimetría de la radiación

Professional Development

19 Qs

Révision HTML, CSS et JavaScript

Révision HTML, CSS et JavaScript

Professional Development

20 Qs

Medición de eficacia Curso Auditores

Medición de eficacia Curso Auditores

Professional Development

20 Qs

C++ Operators

C++ Operators

Assessment

Quiz

Professional Development

Professional Development

Hard

Created by

Zohaib Hasan

Used 301+ times

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

20 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 5 pts

What will be the output of the following code?

int x = 12, y=12;

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

0

1

true

false

Answer explanation

<= means "less than or equal to", it will be true if any one is satisfied

2.

MULTIPLE CHOICE QUESTION

30 sec • 5 pts

What will be the output of the following code?

int x = 2;

cout << x++ << endl;

2

3

Compilation Error

Compiler dependent output

Answer explanation

x++ means "use and then increment"

so x is used (supplied to cout) before incrementing

3.

MULTIPLE CHOICE QUESTION

30 sec • 5 pts

What will be the output of the following code?

int x = 2;

cout << --x << endl;

1

2

Compilation Error

Compiler dependent output

Answer explanation

--x means first decrement and then use.

so x is decremented first and then given to cout

4.

MULTIPLE CHOICE QUESTION

45 sec • 5 pts

What will be the output of the following code?

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

    cout << x;

39

0

38

40

Answer explanation

*, % and / have higher precedence than + and -

4+5*7-6%2/2

=4+35-0/2

=4+35-0

=39

5.

MULTIPLE CHOICE QUESTION

30 sec • 5 pts

What will be the output of the following code?

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

0

1

true

false

Answer explanation

In logical operator && (AND), both the sides of operator should result in true to get true.

true in c++ is printed as 1.

6.

MULTIPLE CHOICE QUESTION

45 sec • 5 pts

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

Answer explanation

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

x>y && ++y

since x>y is false and for && it is the sufficient condition to get result, other side of the && will not be evaluated.

This (x>y && ++y) expression will give 0 (false).

The value of y will remain 6.

7.

MULTIPLE CHOICE QUESTION

45 sec • 5 pts

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

Answer explanation

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

x<y || ++y

since x<y is true and for || it is the sufficient condition to get result, other side of the || will not be evaluated.

This (x<y || ++y) expression will give 1 (true).

The value of y will remain 6.

Create a free account and access millions of resources

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

By signing up, you agree to our Terms of Service & Privacy Policy

Already have an account?