#include <iostream>
int main() {
std::cout << "Hello, World!";
return 0;
}
Explanation:
#include <iostream>
: This line includes the iostream
library, which provides input and output operations in C++. This library is needed to use the std::cout
object and the <<
operator.int main() { ... }
: This is the main function, which is the entry point of a C++ program. The program execution starts from here.std::cout
: std::cout
is an object of the std::ostream
class, which is used to output data to the console.<<
: This is the stream insertion operator, which is used to insert data into the output stream. In this case, it is used to insert the string "Hello, World!" into std::cout
."Hello, World!"
: This is the string that we want to output to the console.;
: The semicolon is used to terminate a statement in C++.return 0;
: This statement returns an exit code of 0, indicating that the program executed successfully.