# Structure of a Program ![rw-book-cover](https://readwise-assets.s3.amazonaws.com/static/images/article2.74d541386bbf.png) ## Metadata - Author: [[cplusplus.com]] - Full Title: Structure of a Program - Category: #articles - Summary: The first program beginners often write in C++ is called "Hello World," which prints the phrase on the screen. C++ programs consist of different components such as comments, preprocessor directives, functions, and statements, all of which help organize the code. To simplify coding, programmers can use "using namespace std;" to avoid writing "std::" before standard library functions like cout. - URL: https://cplusplus.com/doc/tutorial/program_structure/ ## Highlights - Line 2: `#include <iostream>` Lines beginning with a hash sign (`#`) are directives read and interpreted by what is known as the *preprocessor*. They are special lines interpreted before the compilation of the program itself begins. In this case, the directive `#include <iostream>`, instructs the preprocessor to include a section of standard C++ code, known as *header iostream*, that allows to perform standard input and output operations, such as writing the output of this program (Hello World) to the screen. ([View Highlight](https://read.readwise.io/read/01jdbjahn611d6xxps1nhz6ggy)) - The function named `main` is a special function in all C++ programs; it is the function called when the program is run. The execution of all C++ programs begins with the `main` function, regardless of where the function is actually located within the code. ([View Highlight](https://read.readwise.io/read/01jdbjbcvdk41nn0et33fecr3n)) - Line 6: `std::cout << "Hello World!";` This line is a C++ statement. A statement is an expression that can actually produce some effect. It is the meat of a program, specifying its actual behavior. Statements are executed in the same order that they appear within a function's body. This statement has three parts: First, `std::cout`, which identifies the **st**andar**d** **c**haracter **out**put device (usually, this is the computer screen). Second, the insertion operator (`<<`), which indicates that what follows is inserted into `std::cout`. Finally, a sentence within quotes ("Hello world!"), is the content inserted into the standard output. ([View Highlight](https://read.readwise.io/read/01jdbje7vdy69h1vtstn75szjr))