Say “Hello!”
Explore writing your first C++ program by printing a simple greeting to the screen. Understand the role of #include, using namespace, main function, and how to use cout to display output. This lesson helps you build fundamental coding skills with no installation needed.
We'll cover the following...
If you’ve ever wondered how video games, operating systems, or high-performance apps are built, C++ is behind many of them. This course gets you coding right away, no experience needed.
Welcome to C++!
In this lesson, you’ll write and run your very first C++ program. No setup is required. Just you, your keyboard, and a talking machine.
Goal
You’ll aim to:
Write your first line of C++ code.
Use
coutto print to the screen.Understand how a basic C++ program is structured.
Your first C++ program
Let’s write your first C++ program below, which simply prints a greeting to the screen.
Note: Click the ‘‘Run’’ button to execute your code directly in the browser on the Educative platform. You don’t need to install any local setup—everything works conveniently right here!
Click the ‘‘AI Mentor’’ button to have our AI Mentor explain the code and help you understand it better.
That’s your first real C++ program.
What’s happening?
#include <iostream>lets you use input/output features.using namespace std;lets you use keywords likecoutandendlwithout writingcoutorendl.int main()is the starting point of every C++ program.cout <<prints text to the console.<< endladds a line break.return 0;means the program ended successfully.
Instead of using << endl, you can add the newline character \n inside the quotes to create a line break.