Question: i need these solved Look at the following program and answer the question that follows it. They are multiple choice i need the correct one

i need these solved

Look at the following program and answer the question that follows it. They are multiple choice i need the correct one and explanation

1.

What is the output of the following segment of code if the value 4 is input by the user when asked to enter a number?

int num;

int total = 0;

cout << "Enter a number from 1 to 10: ";

cin >> num;

switch (num)

{

case 1:

case 2: total = 5;

case 3: total = 10;

case 4: total = total + 3;

case 8: total = total + 6;

default: total = total + 4;

}

cout << total << endl;

A) 0

B) 3

C) 13

D) 28

E) None of these

2.

Assuming x is 5, y is 6, and z is 8, which of the following is false?

1. x == 5;

2. 7 <= (x + 2);

3. z < = 4;

4. (1 + x) != y;

5. z >= 8;

6. x >= 0;

7. x <= (y * 2)

A) 3, 4, 6, 7 are false.

B) Only 5 is false.

C) 3 and 4 are false.

D) All are false.

E) None of these.

3.

14) What will the following program segment display?

int funny = 7, serious = 15;

funny = serious % 2;

if (funny != 1)

{

funny = 0;

serious = 0;

}

else if (funny == 2)

{

funny = 10;

serious = 10;

}

else

{

funny = 1;

serious = 1;

}

cout << funny << " " << serious << endl;

A) 7 15

B) 0 0

C) 10 10

D) 1 1

E) None of these

4.

15) What will the following program display?

#include

using namespace std;

int main()

{

int a = 0, b = 2, x = 4, y = 0;

cout << (a == b) << " ";

cout << (a != b) << " ";

cout << (b <=x) << " ";

cout << (y > a) << endl;

return 0;

}

A) 0 1 1 0

B) 0 0 1 0

C) 1 1 0 1

D) 1 0 0 1

E) None of these

5.

16) What will the following code display?

int x = 0;

for (int count = 0; count < 3; count++)

x += count;

cout << x << endl;

A) 0

1

2

B) 0

C) 6

D) 3

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!