Chat with us, powered by LiveChat CS 225 – Which of the following IF statements displays | Writedemy

CS 225 – Which of the following IF statements displays

CS 225 – Which of the following IF statements displays

Question

Which of the following IF statements displays Hello?

A) int myVal = 4;

if (myVal < 10)

cout << “Hello”;

else

cout << “Bye”;

B) int myVal = 4;

if (myVal > 10)

cout << “Hello”;

else

cout << “Bye”;

C) int myVal = 10;

if (myVal < 10)

cout << “Hello”;

else

cout << “Bye”;

D) int myVal = 41;

if (myVal < 10)

cout << “Hello”;

else

cout << “Bye”;

Flag this Question

Question 2

Assuming num equals 4, which of the following IF statements is correct if the desired output is

statement1

statement2

A) if (num > 3)

cout << “statement 1” << endl;

cout << “statement 2” << endl;

else

cout << “statement 3” << endl;

cout << “statement 4” << endl;

B) if (num > 3) {

cout << “statement 1” << endl;

cout << “statement 2” << endl;

}

else {

cout << “statement 3” << endl;

cout << “statement 4” << endl;

}

C) if (num > 3)

cout << “statement 1” << endl;

cout << “statement 2” << endl;

else {

cout << “statement 3” << endl;

cout << “statement 4” << endl;

}

D) if (num > 3) {

cout << “statement 1”;

cout << “statement 2”;

}

else {

cout << “statement 3” << endl;

cout << “statement 4” << endl;

}

Flag this Question

Question 3

Assuming variable num equals 4, which of the following IF statements is correct if the desired output is

statement1 statement2

A) if (num > 3)

cout << “statement 1_”;

cout << “statement 2” << endl;

else

cout << “statement 3” << endl;

cout << “statement 4” << endl;

B) if (num > 3) {

cout << “statement 1” << endl;

cout << “statement 2” << endl;

}

else {

cout << “statement 3” << endl;

cout << “statement 4” << endl;

}

C) if (num > 3) {

cout << “statement 1 “;

cout << “statement 2” << endl;

}

else {

cout << “statement 3” << endl;

cout << “statement 4” << endl;

}

D) if (num > 3) {

cout << “statement 1” << endl;

cout << “statement 2”;

}

else {

cout << “statement 3” << endl;

cout << “statement 4” << endl;

}

Flag this Question

Question 4

What is displayed on the console based on the following code fragment?

int num = 2;

if (num == 2)

cout << “On”;

else

cout << “Off”;

A) Off

B) On

C) all of the above

D) none of the above

Flag this Question

Question 510 pts

What is displayed on the console based on the following code fragment?

int num = 3;

if (num == 2)

cout << “On”;

else

cout << “Off”;

Off

On

all of the above

none of the above

Flag this Question

Question 6

What is displayed on the console based on the following code fragment?

int num = 3;

if (num > -102)

cout << “On”;

else

cout << “Off”;

A) Off

B) On

C) all of the above

D) none of the above

Flag this Question

Question 7

What is displayed on the console based on the following code fragment?

int num = -40;

if (num <= 12)

cout << “On”;

else

cout << “Off”;

A) Off

B) On

C) all of the above

D) none of the above

Flag this Question

Question 8

What is displayed on the console based on the following code fragment?

int num = 40;

if (num >= 60) {

cout << “Passed”;

}

else if (num < 60) {

cout << “Failed”;

}

A) Passed

B) Failed

C) all of the above

D) none of the above

Flag this Question

Question 9

What is displayed on the console based on the following code fragment?

int num = 100;

if (num >= 60) {

cout << “Passed”;

}

else if (num < 60) {

cout << “Failed”;

}

A) Passed

B) Failed

C) all of the above

D) none of the above

Flag this Question

Question 10

What is displayed on the console based on the following code fragment?

int num = 78;

if (num >= 90) {

cout<<“Excellent”;

}

else if (num >= 80) {

cout<<“Above Average”;

}

else if (num >= 70) {

cout << “Average”;

}

else if (num >= 60) {

cout<<“Below Average”;

}

else {

cout << “Poor”;

}

A) Excellent

B) Above Average

C) Average

D) Below Average

E) Poor

Flag this Question

Question 11

What is displayed on the console based on the following code fragment?

int num = 8;

if (num >= 90) {

cout<<“Excellent”;

}

else if (num >= 80) {

cout<<“Above Average”;

}

else if (num >= 70) {

cout << “Average”;

}

else if (num >= 60) {

cout<<“Below Average”;

}

else {

cout << “Poor”;

}

A) Excellent

B) Above Average

C) Average

D) Below Average

E) Poor

Flag this Question

Question 12

What is displayed on the console based on the following code fragment?

int num = 91;

if (num >= 90) {

cout<<“Excellent”;

}

else if (num >= 80) {

cout<<“Above Average”;

}

else if (num >= 70) {

cout << “Average”;

}

else if (num >= 60) {

cout<<“Below Average”;

}

else {

cout << “Poor”;

}

A) Excellent

B) Above Average

C) Average

D) Below Average

E) Poor

Flag this Question

Question 13

What is displayed on the console based on the following code fragment?

int num = 91;

if (num >= 90) {

if (num < 100) {

cout<<“Good”;

}

else {

cout << “Bad”;

}

}

A) Bad

B) Good

C) BadGood

D) GoodBad

E) none of the above

Flag this Question

Question 14

What is displayed on the console based on the following code fragment?

int num = 123;

if (num >= 90) {

if (num < 100) {

cout<<“Good”;

}

else {

cout << “Bad”;

}

}

A) Bad

B) Good

C) BadGood

D) GoodBad

E) none of the above

Flag this Question

Question 1510 pts

In a ____ control structure, the computer executes particular statements depending on some condition(s).

A) looping

B) repetition

C) selection

D) sequence

Flag this Question

Question 16

What does <= mean?

A) less than

B) greater than

C) less than or equal to

D) greater than or equal to

Flag this Question

Question 17

Which of the following is the “not equal to” relational operator?

A) !

B) |

C) !=

D) &

Flag this Question

Question 18

Suppose x is 5 and y is 7. Choose the value of the following expression:

A) (x != 7) && (x <= y)

B) false

C) true

D) 0

E) null

Flag this Question

Question 19

Suppose that x is an int variable. Which of the following expressions always evaluates to true?

A) (x > 0) || ( x <= 0)

B) (x >= 0) || (x == 0)

C) (x > 0) && ( x <= 0)

D) (x > 0) && (x == 0)

Flag this Question

Question 20

The expression in an if statement is sometimes called a(n) ____.

A) selection statement

B) action statement

C) decision maker

D) action maker

Flag this Question

Question 21

When one control statement is located within another, it is said to be ____.

A) blocked

B) compound

C) nested

D) closed

Flag this Question

Question 22

The appearance of = in place of == resembles a(n) ____.

A) syntax error

B) silent killer

C) compilation error

D) input failure

Flag this Question

Question 23

What is the output of the following code?

char lastInitial = ‘S’;

switch (lastInitial)

{

case ‘A’:

cout << “section 1” <<endl;

break;

case ‘B’:

cout << “section 2” <<endl;

break;

case ‘C’:

cout << “section 3” <<endl;

break;

case ‘D’:

cout << “section 4” <<endl;

break;

default:

cout << “section 5” <<endl;

}

A) section 2

B) section 3

C) section 4

D) section 5

Flag this Question

Question 24

What is the output of the following code?

char lastInitial = ‘A’;

switch (lastInitial)

{

case ‘A’:

cout << “section 1” <<endl;

break;

case ‘B’:

cout << “section 2” <<endl;

break;

case ‘C’:

cout << “section 3” <<endl;

break;

case ‘D’:

cout << “section 4” <<endl;

break;

default:

cout << “section 5” <<endl;

}

A) section 1

B) section 2

C) section 3

D) section 5

Flag this Question

Question 25

What is the output of the following code fragment if the input value is 4?

int num;

int alpha = 10;

cin >> num;

switch (num)

{

case 3:

alpha++;

break;

case 4:

case 6:

alpha = alpha + 3;

case 8:

alpha = alpha + 4;

break;

default:

alpha = alpha + 5;

}

cout << alpha << endl;

A) 13

B) 14

C) 17

D) 22

Flag this Question

Question 26

What is the output of the following C++ code?

int x = 55;

int y = 5;

switch (x % 7)

{

case 0:

case 1:

y++;

case 2:

case 3:

y = y + 2;

case 4:

break;

case 5:

case 6:

y = y – 3;

}

cout << y << endl;

A) 2

B) 5

C) 8

D) 10

Flag this Question

Question 27

In ____ structures, the computer repeats particular statements a certain number of times depending on some condition(s).

looping

branching

selection

sequence

Flag this Question

Question 2810 pts

What is the output of the following C++ code?

num = 10;

while (num > 10)

num = num – 2;

cout << num << endl;

A) 0

B) 6

C) 8

D) 10

Flag this Question

Question 29

What is the output of the following C++ code?

num = 100;

while (num <= 150)

num = num + 5;

cout << num << endl;

A) 150

B) 155

C) 160

D) 165

Flag this Question

Question 30

A loop that continues to execute endlessly is called a(n) ____ loop.

A) end

B) unhinged

C) infinite

D) definite

Flag this Question

Question 31

Consider the following code.

int limit;

int reps = 0;

int entry;

int triple;

cin >> limit;

while (reps < limit)

{

cin >> entry;

triple = entry * 3;

cout << triple;

reps++;

}

cout << endl;

This code is an example of a(n) ____ while loop.

A) flag-controlled

B) counter-controlled

C) EOF-controlled

D) sentinel-controlled

Flag this Question

Question 32

A(n) ____-controlled while loop uses a bool variable to control the loop.

A) counter

B) sentinel

C) flag

D) EOF

Flag this Question

Question 33

Which of the following statements generates a random number between 0 and 50?

A) srand(time(0));

num = rand() % 50;

B) srand(time(10));

num = rand()/50;

C) srand(time(0));

num = rand()50;

D) srand(time(10));

num = rand() % 50;

Flag this Question

Question 34

What is the next Fibonacci number in the following sequence?

1, 1, 2, 3, 5, 8, 13, 21, …

A) 34

B) 43

C) 56

D) 273

Flag this Question

Question 35

What is the initial statement in the following for loop? (Assume that all variables are properly declared.)

int i;

for (i = 1; i < 20; i++)

cout << “Hello World”;

cout << “!” << endl;

A) i = 1;

B) i < 20;

C) i++;

D) cout << “Hello World”;

Flag this Question

Question 36

What is the output of the following C++ code?

int j;

for (j = 10; j <= 10; j++)

cout << j << ” “;

cout << j << endl;

A) 10

B) 10 10

C) 10 11

D) 11 11

Flag this Question

Question 37

Which of the following is a repetition structure in C++?

A) if

B) switch

C) while…do

D) do…while

Flag this Question

Question 38

What is the value of x after the following statements execute?

int x = 5;

int y = 30;

do

x = x * 2;

while (x < y);

A) 5

B) 10

C) 20

D) 40

Flag this Question

Question 39

What is the output of the following loop?

count = 5;

cout << ‘St’;

do

{

cout << ‘o’;

count–;

}

while (count <= 5);

A) St

B) Sto

C) Stop

D) This is an infinite loop.

Flag this Question

Question 40

____ loops are called posttest loops.

A) break

B) for

C) while

D) do…while

Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.

Do you need an answer to this or any other questions?

About Writedemy

We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.

How It Works

To make an Order you only need to click on “Order Now” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Are there Discounts?

All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.

Hire a tutor today CLICK HERE to make your first order