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

Respuesta :

Answer:

(a) C++ is fun.

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.