4.1k views
1 vote
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;

User Foitn
by
6.7k points

2 Answers

4 votes

Answer:

11

Step-by-step explanation:

User Hahcho
by
7.4k points
4 votes

Answer:

1 1

Step-by-step explanation:

The statement funny = serious % 2 assigns 1 to funny, since the remainder of 15 divided by 2 is 1.

Then the last else clause of the program kicks in, assigning 1 to both funny and serious.

User Nickbusted
by
7.1k points