Search Header Logo

If Statements review

Authored by Lioubov Rogalskaia

Other

12th Grade

Used 3+ times

If Statements review
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

5 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Of the following if statements, which one correctly executes three instructions if the

condition is true?

if (x < 0)

a = b * 2;

y = x;

z = a – y;

{

if (x < 0)

a = b * 2;

y = x;

z = a – y;

}

if { (x < 0)

a = b * 2;

y = x;

z = a – y ;

}

if (x < 0)

{

a = b * 2;

y = x;

z = a – y;

}

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the sets of statements below will add 1 to x if x is positive and subtract 1 from x if x is negative but leave x alone if x is 0?

if (x > 0) x++;

else x--;

if (x > 0) x++;

else if (x < 0) x--;

if (x > 0) x++;

if (x < 0) x--;

else x = 0;

if (x == 0) x = 0;

else x++;

x--;

3.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

If x is currently 0, a = 5

and b = 5, what will x become after the statement is executed?


if (a > 0)

if (b < 0)

x = x + 5;

else

if (a > 5)

x = x + 4;

else

x = x + 3;

else

x = x + 2;

0

2

3

4

5

4.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

If x is currently 0, a = 0

and b = - 5, what will x become after the statement is executed?


if (a > 0)

if (b < 0)

x = x + 5;

else

if (a > 5)

x = x + 4;

else

x = x + 3;

else

x = x + 2;

0

2

3

4

5

5.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

If x is currently 0, a = 1

and b = -1, what will x become after the statement is executed?


if (a > 0)

if (b < 0)

x = x + 5;

else

if (a > 5)

x = x + 4;

else

x = x + 3;

else

x = x + 2;

0

2

3

4

5

Access all questions and much more by creating a free account

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

Already have an account?