Solution: Print More Greetings

This C++ program demonstrates how to print multiple lines of text to the console using the cout statement.

  1. Header and namespace

    1. #include <iostream> includes the input/output stream library, which allows the program to use cout for printing text.

    2. using namespace std; lets us use standard library objects (like cout and endl) without writing std:: before them.

  2. Main function

    1. The program starts executing from the main() function.

    2. Each cout statement outputs a line of text to the console, followed by << endl; which moves the cursor to the next line.

  3. Output lines

    1. cout << "I'm learning C++!" << endl; prints the first message.

    2. cout << "Welcome to the machine." << endl; prints the second message.

    3. cout << "Let's write some code!" << endl; prints the third message.

  4. Return statement

    1. return 0; indicates successful program completion.

Solution: Print More Greetings

This C++ program demonstrates how to print multiple lines of text to the console using the cout statement.

  1. Header and namespace

    1. #include <iostream> includes the input/output stream library, which allows the program to use cout for printing text.

    2. using namespace std; lets us use standard library objects (like cout and endl) without writing std:: before them.

  2. Main function

    1. The program starts executing from the main() function.

    2. Each cout statement outputs a line of text to the console, followed by << endl; which moves the cursor to the next line.

  3. Output lines

    1. cout << "I'm learning C++!" << endl; prints the first message.

    2. cout << "Welcome to the machine." << endl; prints the second message.

    3. cout << "Let's write some code!" << endl; prints the third message.

  4. Return statement

    1. return 0; indicates successful program completion.