Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Class notes

c language

Rating
-
Sold
-
Pages
5
Uploaded on
26-02-2023
Written in
2021/2022

I am providing best study document its help you to learn programing and I provided all document of computer application

Institution
Course

Content preview

C Preprocessor
Build Process:

1. The C programming language is a high-level language, but computers
cannot understand this language directly.
2. Computers are able to execute your programs because the programs that
you write in the C language first go through a ‘build process’ and are
finally converted into an executable code, which can be understood by a
computer.
3. To summarise, various steps are involved from writing a C program to
getting it executed. The combination of these steps is known as the ‘build
process’. These steps are as follows: ○ Preprocessing ○ Compiling ○
Assembling ○ Linking ○ Loading
The detailed ‘build process’ is as follows:
4. The C program that you write in a text editor is known as a ‘source code’.
5. It goes through a preprocessor that expands the source code, after which
you obtain an expanded source code.
6. This expanded source code is then converted into an assembly code by a
compiler.
7. The assembler then converts this assembly code into a relocatable object
code.
8. Finally, the linker combines this relocatable object code with the object
code of library functions, which is used in the code, to form an executable
code
9. Preprocessor Directives:
10. The reprocessor offers several features called ‘preprocessor
directives’. Some of these preprocessor directives are as follows:
1. File inclusion
2. Macro expansion
3. Conditional compilation

File Inclusion:

File inclusion is used to include all the file contents that are used in

the program.

The preprocessor command for file inclusion looks like the following:

#include "filename" or #include This command simply allows all the
contents of the filename to be inserted into the source code at that point
in the program, assuming that the file being included exists.
1. #include”filename” command is used to search the file in the current directory first and
then in the include directory.
2. The #include command searches the file only in the include directory. Is cellaneous
directives
3. Macro Expansion:
4. The #define command is used to define a macro.

Example:

, #define LOWER 5

#include<stdio.h>

int main()

{ printf("%d", LOWER);

}

‘LOWER’ is known as a macro template, and ‘5’ is known as a macro expansion.

1. Every template gets replaced by its expansion.
2. Macros have a global effect.
3. This can be used when a constant value appears at multiple places in the program.

Example:

Suppose you need to write a C program to find the curved surface area, the
total surface area or the volume of a sphere (given its radius). All these formulas
use the value of pi, i.e., 3.14. Now, rather than writing the value of pi (3.14)
multiple times in a single program, you can make use of macro as follows:

#define PI 3.14

1. Macros are of two types, which are as follows:
2. Simple macros ○ Macros with argument

Example:

# include<stdio.h>

# define PI 3.14

# define AREA( x ) PI * x * x

float area ( float ) ;

int main( )

{

float r, a ;

scanf ( "%f", &r ) ;

a = AREA ( r ) ;

printf ( "\n%f", a ) ;

a = area ( r ) ;

printf ( "\n%f", a ) ;

}

float area ( float rr )

Written for

Institution
Course

Document information

Uploaded on
February 26, 2023
Number of pages
5
Written in
2021/2022
Type
Class notes
Professor(s)
Aquib ajani
Contains
All classes

Subjects

$8.49
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
satyamsingh199743

Get to know the seller

Seller avatar
satyamsingh199743 Chandigarh University
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
3 year
Number of followers
0
Documents
1
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions