Skip to main content

Introduction to Programming: Program Structure in C++

 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:

  1. Header Files
  2. std namespace
  3. main function
  4. 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

Popular posts from this blog

Programming Fundamental: Datatypes and Variable Declaration

In every programming language, there are some key elements are used. These key elements are the building blocks of any programming language. In this particular blog post, we will discuss about two of them. These are as follows: Variables Data Type     What is a Variable? A variable is like a labeled box in a computer's memory (RAM) where you can store information. It's given a specific name to help you access and manipulate the stored data during program execution. These stored values can change as the program runs. Variable Declaration   Variable declaration is the process of specifying the data type a variable will hold. Data types define the kind of data a variable can store, such as numbers, text, or other types. Variable Initialization Variable initialization involves assigning an initial value to a variable during its declaration or at a later point in the program. The following picture will display the example of the variable declaration and initialization. What is...