High five! We just got your first program to run.
C++, like most programming languages, runs line by line, from top to bottom. Here is the structure of a C++ program:
In between the curly braces is what we are going to focus on for now.
std::cout << "Hello World!\n";
std::coutis the “character output stream”. It is pronounced “see-out”.
<<is an operator that comes right after it.
"Hello World!\n"is what’s being outputted here. You need double quotes around text. The
\nis a special character that indicates a new line.
;is a punctuation that tells the computer that you are at the end of a statement. It is similar to a period in a sentence.
Let’s write the whole
std::cout statement from scratch.
Inside the curly braces, type the following and press Run:
std::cout << "Codecademy\n";
What do you think this program will output?