What is a Program Structure in C++?
A program structure is a set of statements that are part of every C++ program. In this particular blog post, we will learn about these statements. There are the following parts of the C++ program structure:
- Header Files
- std namespace
- main function
- return 0
1: Header Files
The header files are the pre-programmed files, which are useful while writing the programs. These files contain some important information that is necessary for the successful execution of the programs. These files are programmed by the developer of the language. In the above figure, "#include<iostream>" is a header file.
2: namespace std
The namespace std is the latest addition to the C++ compilers, which tells the compilers to use the namespace std. The second line in the above diagram "using namespace std".
3: main function
The actual execution of every program begins with the main() function. All the program statements are written between the curly braces of the main() function. 3rd line in the diagram describes the syntax of the main() function "int main()".
4: return 0
The program should return the value of 0 after the successful execution of the program statements.
Note: In the curly braces{ } the program statements are written. The semicolon (;) is used to terminate a program statement. Every program statement ends with the semicolon, otherwise, the compiler generates an error.
Comments
Post a Comment