C++

C++ is a general-purpose coding language. C++ runs line by line, from top to bottom.

// A comment

#include <iostream>

int main() {
  std::cout << "Hello World!\n" ; 
  retutn 0;
}

#include <iostream> is known as a pre-processor directive. It instructs the compiler to locate the file that contains code for a library known as iostream. This library contains code that allows for input and output, such as displaying data in the terminal window or reading input from your keyboard.

Every C++ program must have a function called main(). A function is basically a sequence of instructions for the computer to execute. This main() function houses all of our instructions for our program.

<< is an operator that comes right after it.

\n is 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.

The return statement is used to end a function. If the program reaches this statement, returning a value of 0 is an indication to the operating system that the code executed successfully. This line of code is optional.

Last updated