0% found this document useful (0 votes)
3 views1 page

C++ Program Structure Notes

The document outlines the structure of a C++ program, which includes sections for documentation, linking header files, defining constants, declaring global variables, the main function, and user-defined functions. An example program demonstrates these components, showcasing the use of input and output along with a simple addition function. The provided code illustrates the practical application of the discussed structure.

Uploaded by

pappu CSE
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

C++ Program Structure Notes

The document outlines the structure of a C++ program, which includes sections for documentation, linking header files, defining constants, declaring global variables, the main function, and user-defined functions. An example program demonstrates these components, showcasing the use of input and output along with a simple addition function. The provided code illustrates the practical application of the discussed structure.

Uploaded by

pappu CSE
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

STRUCTURE OF A C++ PROGRAM

1. Documentation Section:
Used for comments describing the program.

2. Link Section:
Includes header files using #include.

3. Definition Section:
Defines constants using #define.

4. Global Declaration Section:


Declares global variables and functions.

5. main() Function:
Execution starts from main().

6. User-defined Functions:
Contains functions outside main().

Example Program:

Example Program Code:


#include <iostream>
using namespace std;
#define PI 3.14
int a,b;
int add(int x,int y){ return x+y; }
int main(){
cin>>a>>b;
cout<<add(a,b);
return 0;
}

You might also like