how to print a word in c++
#include <iostream>
int main() {
std::cout << "Hello, World!" << std::endl;
return 0;
}
Explanation:
#include <iostream>
: This line includes the input/output stream library, allowing input and output operations.int main() { }
: This is the main function where the execution of the program begins.int
indicates that the function returns an integer value.std::cout << "Hello, World!" << std::endl;
: This line prints the string "Hello, World!" to the console.std::cout
represents the standard output stream. The<<
operator is used to insert the string into the output stream.std::endl
is used to insert a newline character and flush the stream.return 0;
: This statement signifies the end of themain
function and returns 0 to indicate successful program execution to the operating system.