Home »
MCQs »
C++ MCQs
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:
- Hello World
- Hello
- Error
- 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;
}