106k views
3 votes
What will the following segment of code output if 11 is entered at the keyboard?

int number;

cin >> number;

if (number > 0)

cout << "C++";

else

cout << "Soccer";

cout << " is ";

cout << "fun" << endl;

a.
C++ is fun

b.
Soccer is fun

c.
C++

d.
C++fun

User Sok Chanty
by
6.6k points

1 Answer

4 votes

Answer:

(a) C++ is fun.

Step-by-step explanation:

The output is like this because when 11 is entered it is greater than 0 so the if statement is true so lines code in if will be executed cout<<"Soccer"; is the part of else . Other cout are part of the main function so they will also be executed.So the output is C++ is fun.

User Richie Li
by
6.6k points