You are on page 1of 9

01

02

C Language
LECTURE 3
04
Today’s Agenda

01 Processing Of The Program In C Language

02 What is The Symbol Of ‘#’ and Why do


We Write “#include” ?

03
What is Pre-Processor ?
Processing Of The Program In C Language
SOURCE CODE EXPANDED SOURCE CODE Machine Code
#include <stdio.h> ……………………… 01010101111
#include <conio.h> ………………………. 01010111010
void main() void main() Compiler 10100010101
{ Preprocessor { 11001010010
clrscr(); clrscr();
printf(“Hello User”); printf(“Hello User”);
} }

Output
No. of Lines 7 No. of Lines 461 O.S
Hello User
What is ‘#’ and Why do We Write “#include” ?

 What is the symbol of ‘#’ called and why do we write #include ?

o The Symbol of ‘#’ in C/C++ is called as ‘POUND” and any statement of


our program which begins with ‘#’ PRE-PROCESSOR DEIRECTIVE.

o These PRE-PROCESSOR DIRECTIVES are special statements which are


not evaluated by the compiler rather they are evaluated by a special
software built in to C language which is called as the PRE-PROCESSOR.
What is ‘#’ and Why do We Write “#include” ?

o This PRE-PROCESSOR reads our program before the compiler and only
handles those line which begins with the symbol of ‘#’.

 Following are important PRE-PROCESSOR DIRECTIVES provided by C language.

1. #include : File Inclusion Directive

2. #define : Macro Creation Directive

3. #undef : Macro Removal Directive


Important Pre-Processor Directives

4. #if #elif
#else #endif Conditional Compilation Directive
#ifdef #ifndef

o Amongst them, then most popular between programmers is the #include


directive which is used by programmers for including HEADER FILE SUPPORT
in their programs
Pre-Processor Steps

o Whenever the PRE-PROCESSOR, reads a #include directive in our program


then it takes the following steps:

1. It reads the header file name given in angular brackets and locates
that file in our computer.

2. It then copies the complete code (FUNCTIONS) present in the


header file in our program and deletes the #include statement.
Pre-Processor Steps

3. Due to this no. of lines in our program are increased an a separate copy of our code
gets created which is called as “EXPANDED SOURCE CODE”.

o This EXPANDED SOURCE CODE then goes to the compiler, which converts it
into MACHINE CODE.

o Finally this MACHINE CODE goes to the OS and CPU which run it and we
get the desired output.
End of Lecture 3
For any queries mail us @: scalive4u@gmail.com
Call us @ : 0755-4271659, 7879165533

Thank you

You might also like