Vidyalelo
C++ Programming · Q73

Introduction to C++

Programming · C++ Programming · question 73

Q73

What will be the output of the following C++ code? #include int main(int argc, char const *argv[]) cout<<"Hello World"; return 0;

A.
Hello World
Answer
B.
Compile-time error
C.
Run-time error
D.
Segmentation fault

Answer: Option A

Solution

Answer: Option A
Solution:
The given code is a basic C++ program that prints a message to the console.

It includes the <iostream> header, which allows the use of input and output streams like cout.

The main function is defined correctly with appropriate parameters (int argc, char const *argv[]), though these parameters are not used.

cout<<"Hello World"; correctly outputs the text "Hello World" to the standard output.

There are no syntax or runtime errors in the code, and it will compile and run successfully.

Therefore, the output will be: Hello World