Computer Science SLO Based Key Point Notes

👉👉👉 Computer Science 12th Class Notes (Main Page)

************************************

Unit 3: Object-Oriented Programming in C++


3.1.3 Structure of C++ Program

The format or way according to which a computer program is written is called the structure of the program.
The basic structure of a C++ program consists of the following main parts:
  1. Preprocessor Directives
  2. The main() function
  3. Program Body (C statements)
Example


Preprocessor Directive

  • The instructions given to the C-compiler before the compilation process are called preprocessor Directive.
  • They are also known as Compiler Directive.
  • They are given at the beginning of the source code.
  • They are processed before compiling the source code by a program known as Preprocessor which is a part of a C-compiler.
  • Preprocessor Directive begins with a “#” sign.

Following are the important types of preprocessor Directive:
i.    Include directive
ii.   define directive

i. Include directive

The “include preprocessor directive” is used to include header files in the program.

The syntax of using “include directive is as follows 

                            #include < Header file name. h >

Many header files can be included in one program.

ii. Define directive

Define directive is used to define a constant.
It starts with the # symbol.

The syntax of the defined directive is as follows:

            #define identifier expression

Example:
            #define pi 3.14


main() function

  • The main() function is the place where the execution of a C program starts.
  • Every C program must have the main() function.
  • If a program does not contain the main() function, it can be compiled but cannot be executed.
  • The body of the main function is enclosed in curly braces { } which contain a statement.

The syntax of the main() function is as follows:

void main(void)
{
        body of the main function which contains statements;
}


👇👇👇👇👇👇👇👇👇👇👇👇


************************************
👉👉👉 Computer Science 12th Class Notes (Main Page)

************************************



(National Book Foundation - As Federal Textbook Board, Islamabad 
Based on National Curriculum Pakistan 2026-2027 and Onward prescribed by Federal Board of Intermediate and Secondary Education, Islamabad, and All Pakistan Boards) 

{Contact WhatsApp # +923339719149 for Class-XII Computer Science Complete SLO-Based Key Points notes in pdf format as well as in PowerPoint Presentation for preparing/delivering the Lectures}

Note:  Write me in the comments box below for any query and also Share this information with your class-fellows and friends.