0
0
C++programming~15 mins

Using cout for output in C++ - Mini Project: Build & Apply

Choose your learning style9 modes available
Using cout for output
📖 Scenario: You are learning how to display messages on the screen using C++.Imagine you want to greet someone by showing a message.
🎯 Goal: Build a simple C++ program that uses cout to print a greeting message.
📋 What You'll Learn
Create a string variable with a greeting message
Use cout to display the greeting message
Include the necessary header and namespace for cout
💡 Why This Matters
🌍 Real World
Displaying messages is the first step in making interactive programs like games, calculators, or chat apps.
💼 Career
Knowing how to output text is essential for debugging and communicating with users in software development.
Progress0 / 4 steps
1
Create a string variable with the greeting message
Create a string variable called greeting and set it to "Hello, friend!"
C++
Need a hint?

Use string greeting = "Hello, friend!"; inside main().

2
Add the cout statement to display the greeting
Use cout to print the variable greeting followed by endl
C++
Need a hint?

Write cout << greeting << endl; to show the message.

3
Add a second message using cout
Use cout to print the exact text "Welcome to C++ programming!" followed by endl
C++
Need a hint?

Write cout << "Welcome to C++ programming!" << endl; below the first cout.

4
Print both messages to the screen
Run the program so it prints both messages exactly as shown:
Hello, friend!
Welcome to C++ programming!
C++
Need a hint?

Make sure your program prints both lines exactly.