What will be the output of the following C++ program (1)?

104. What will be the output of the following program?

#include <iostream>
using namespace std;

void sayHello();
{
    cout << "Hello World";
}

int main()
{
    sayHello();
    return 0;
}

Options:

  1. Hello World
  2. Hello
  3. Error
  4. None of the above

Answer: B) CSS

Explanation:

The above program will generate a syntax error because we use a semicolon in the definition of the sayHello() function. The correct program is given below:

#include <iostream>
using namespace std;

void sayHello()
{
    cout << "Hello World";
}

int main()
{
    sayHello();
    return 0;
}

Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.