Welcome to C++
A program is a set of instructions a computer can carry out. In this course, you will write small C++ programs that display messages, calculate useful values, and make decisions. You do not need to install anything to begin: the examples and coding lessons run here.
Start with a program that writes a greeting. Press Run on the code block below. The Console should show Hello, neighbor!.
#include <iostream>
int main() {
std::cout << "Hello, neighbor!" << "\n";
return 0;
}
The code above is the source: the instructions written for the computer. When you press Run, a compiler checks and translates that source before the program executes. The Console shows the output produced by the running program. In this example, that is just the greeting; the quotes and semicolon belong to the source, so they do not appear in the message.
Read just the message line first
std::cout is C++'s standard output stream. Think of << as sending the value on its right into that stream. The text between double quotes is a string literal: text written directly in the program. The quotes mark where the text starts and ends; they are not printed.
"\n" means a newline, so subsequent output starts on a new line. The semicolon ends the instruction. For now, leave the surrounding #include, main, braces, and return in place. We will read those parts shortly.
This block is a worked example, not an editable assignment. In the next lesson, the main.cpp editor will contain a similar program. You will change one message, press Run to see what happened, then press Submit to check the requested result. An unsuccessful check means there is something to adjust; you can edit and try again.