55.5k views
1 vote
(TCO 4) 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 = 3; serious = 3; } cout << funny << " " << serious << endl; }

User Abronan
by
5.0k points

2 Answers

4 votes

Answer:

It'll be 3 3. Just because i think it is, duh

Step-by-step explanation:

User Emmanuel Guiton
by
6.2k points
4 votes

Answer:

3 3

Step-by-step explanation:

The operator modulus '%' is gives the reminder of the number.

for example:

7%2 it gives the result 1 because 1 is reminder after divided by 2.

Initially the value of funny is 7 and serious is 15.

then, 15 is modulus by 2 which gives 1 and it store in the funny.

After that, if else statement check for condition.

funny != 1 this condition is FALSE because Funny is equal to 1.

it moves to else if part Funny == 2 condition again FALSE it then move to else part and execute the statement Funny contain 3 and serious contain 3.

and then display.

Therefore, the answer 3 3.

User Joyell
by
6.5k points