> For the complete documentation index, see [llms.txt](https://mr-poston-1.gitbook.io/c++/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mr-poston-1.gitbook.io/c++/1.-c++-basics/1.1-input-output-and-program-structure/1.1.5-program-structure.md).

# 1.1.5 Program Structure

Earlier you saw a little about program structure, but let’s look at a few additional details. It is important to understand that C++ is mainly an object oriented language like Java, but it does share some structural language components, similar to Python.

* C++ reads from top to bottom, so things like functions need to be defined above their call statement.
* Since C++ is not a pure Object Oriented language, you can define variables, functions, etc. outside of any function or class.
* You can add comments to your code in a similar fashion to Java, using /\* \*/ for multiline comments and // for single line comments.

![](https://codehs.com/uploads/52e169c46622b89bb42cbda9084e0314)

## Program Flow

Like other languages, a C++ program has a common structure or flow to it. In the first lines of the program, you write any include statements. Libraries from the Standard (std) library are added with the name between `<` and `>`.

After the import statements, you would then write any `namespace` statements. In this course, we will use the `using namespace std;` statement for all our programs.

From there, you can now start declaring variables and/or functions. Remember, the order is important, so you will often define variables and functions before the main function. While the main function is where the program starts execution, C++ will only recognize variables and functions that have been seen above in the code.

{% embed url="<https://onlinegdb.com/VLa7Nz_RT>" %}
Program Structure
{% endembed %}
