Group
Introduction to C++
Objective
1. Include the necessary header file `iostream` to use the `cout` object.
2. Write the `main()` function, which is the entry point of every C++ program.
3. Use the `cout` object to print "Hello, World!" to the console.
4. Ensure that the program compiles and runs without errors, displaying the correct output.
Write a program that prints "Hello, World!"
Example C++ Exercise
Show C++ Code
#include <iostream> // Include the iostream library to handle input and output
using namespace std; // Use the standard namespace for convenience
// Main function - the entry point of the program
int main() {
// Output "Hello, World!" to the console
cout << "Hello, World!" << endl; // cout is used to print to the console and endl adds a new line
return 0; // Return 0 to indicate that the program ran successfully
}
Output
Hello, World!