SlideShare a Scribd company logo
2
Most read
4
Most read
5
Most read
C
Preprocessors
Macro
Simple
Parameterized
By Asst. Prof. Sonali Gholve- Doifode
Preprocessor
C
Source code
Preprocessor Compiler
• Preprocessor is a collection of special statements,
called directives, that are executed at the beginning
of the compilation process.
• #
• Eg. #include => include the header file into
the program.
• #include<stdio.h>, #include<string.h>
Macro
• What is macro?
• Macro is a small part of a code that is given a
name. Whenever the name is used, it is
replaced by the contents of the macro.
• you can define macro in C using #define
preprocessor directive
• Simple macro substitution
• Parameterized macro/function like macro
Simple macro substitution
• It is used to simple replacement of identifier by string.
• Eg. To calculate area of circle using macro
#include<stdio.h>
#define PI 3.14
int main()
{
float rad, area;
printf(“ Enter the radius”);
scanf(“%f”,&rad);
area=PI *rad*rad;
printf(“Area of circle=%f”, area);
return 0;
}
Parameterized macro/Function like
macro substitution
• Macro that takes the parameter.
• Eg. To calculate square of number using macro
#include<stdio.h>
#define square (x) ((x)*x)
int main()
{
int p;
p=square(5);
printf(“n Square of 5 is=%d”, p);
return 0;
}

More Related Content

PDF
Python recursion
PPTX
INLINE FUNCTION IN C++
PPTX
Loops in c programming
PPTX
Constructor and Types of Constructors
PPTX
PPTX
User defined function in c
PDF
Types of pointer in C
PPTX
Python-Classes.pptx
Python recursion
INLINE FUNCTION IN C++
Loops in c programming
Constructor and Types of Constructors
User defined function in c
Types of pointer in C
Python-Classes.pptx

What's hot (20)

PDF
Data Structures & Algorithm design using C
PPTX
classes and objects in C++
PPTX
Static Data Members and Member Functions
PPT
One Dimensional Array
PPTX
Delegates and events in C#
PPT
Input and output in C++
PPTX
Preprocessor
PDF
Control Structures in Python
PPTX
constructors in java ppt
PPTX
Introduction to problem solving in C
PPT
C++ Language
PPTX
PPTX
Exception Handling in C++
PPTX
Unit I - Evaluation of expression
PPTX
Looping statements in C
PPT
1. over view and history of c
PDF
Python modules
PPTX
Intro to c++
PPT
Operator Overloading
PPTX
Friend function
Data Structures & Algorithm design using C
classes and objects in C++
Static Data Members and Member Functions
One Dimensional Array
Delegates and events in C#
Input and output in C++
Preprocessor
Control Structures in Python
constructors in java ppt
Introduction to problem solving in C
C++ Language
Exception Handling in C++
Unit I - Evaluation of expression
Looping statements in C
1. over view and history of c
Python modules
Intro to c++
Operator Overloading
Friend function
Ad

Similar to Macro and Preprocessor in c programming (20)

PPTX
DOCX
Unit 5 quesn b ans5
PPTX
Preprocessor directives in c language
PPTX
Preprocessor directives in c laguage
PDF
5. Functions in C.pdf
PDF
ANSI C Macros
PPTX
STRUCTURED PROGRAMMING (USING C PROGRAMMING).pptx
PDF
Unit 5 Part 1 Macros
PDF
Learning the C Language
PPTX
Functions and Header files ver very useful
PDF
Presentation1.pdf programing fundamental
PDF
0100_Embeded_C_CompilationProcess.pdf
PPTX
C-Programming C LIBRARIES AND USER DEFINED LIBRARIES.pptx
PPTX
C-Programming C LIBRARIES AND USER DEFINED LIBRARIES.pptx
PDF
6 preprocessor macro header
PPTX
Unit-IV.pptx
PPT
PreProcessorDirective.ppt
PPTX
introduction of c langauge(I unit)
PDF
C Programming Tutorial - www.infomtec.com
PPTX
# And ## operators in c
Unit 5 quesn b ans5
Preprocessor directives in c language
Preprocessor directives in c laguage
5. Functions in C.pdf
ANSI C Macros
STRUCTURED PROGRAMMING (USING C PROGRAMMING).pptx
Unit 5 Part 1 Macros
Learning the C Language
Functions and Header files ver very useful
Presentation1.pdf programing fundamental
0100_Embeded_C_CompilationProcess.pdf
C-Programming C LIBRARIES AND USER DEFINED LIBRARIES.pptx
C-Programming C LIBRARIES AND USER DEFINED LIBRARIES.pptx
6 preprocessor macro header
Unit-IV.pptx
PreProcessorDirective.ppt
introduction of c langauge(I unit)
C Programming Tutorial - www.infomtec.com
# And ## operators in c
Ad

More from ProfSonaliGholveDoif (6)

PPTX
Searching in Artificial Intelligence for UG
PPTX
Artificial Intelligence Basics part 1 for UG students
PPTX
Introduction to Data Structure part 1
PPTX
Inheritance in c++theory
PPTX
File handling in c++
PPTX
String predefined functions in C programming
Searching in Artificial Intelligence for UG
Artificial Intelligence Basics part 1 for UG students
Introduction to Data Structure part 1
Inheritance in c++theory
File handling in c++
String predefined functions in C programming

Recently uploaded (20)

PPTX
CHAPTER 2 - PM Management and IT Context
PPTX
L1 - Introduction to python Backend.pptx
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
System and Network Administraation Chapter 3
PPTX
Online Work Permit System for Fast Permit Processing
PDF
AI in Product Development-omnex systems
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
Digital Strategies for Manufacturing Companies
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PPTX
Odoo POS Development Services by CandidRoot Solutions
CHAPTER 2 - PM Management and IT Context
L1 - Introduction to python Backend.pptx
Odoo Companies in India – Driving Business Transformation.pdf
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Which alternative to Crystal Reports is best for small or large businesses.pdf
System and Network Administraation Chapter 3
Online Work Permit System for Fast Permit Processing
AI in Product Development-omnex systems
Design an Analysis of Algorithms I-SECS-1021-03
PTS Company Brochure 2025 (1).pdf.......
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Upgrade and Innovation Strategies for SAP ERP Customers
Softaken Excel to vCard Converter Software.pdf
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Digital Strategies for Manufacturing Companies
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
VVF-Customer-Presentation2025-Ver1.9.pptx
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Odoo POS Development Services by CandidRoot Solutions

Macro and Preprocessor in c programming

  • 2. Preprocessor C Source code Preprocessor Compiler • Preprocessor is a collection of special statements, called directives, that are executed at the beginning of the compilation process. • # • Eg. #include => include the header file into the program. • #include<stdio.h>, #include<string.h>
  • 3. Macro • What is macro? • Macro is a small part of a code that is given a name. Whenever the name is used, it is replaced by the contents of the macro. • you can define macro in C using #define preprocessor directive • Simple macro substitution • Parameterized macro/function like macro
  • 4. Simple macro substitution • It is used to simple replacement of identifier by string. • Eg. To calculate area of circle using macro #include<stdio.h> #define PI 3.14 int main() { float rad, area; printf(“ Enter the radius”); scanf(“%f”,&rad); area=PI *rad*rad; printf(“Area of circle=%f”, area); return 0; }
  • 5. Parameterized macro/Function like macro substitution • Macro that takes the parameter. • Eg. To calculate square of number using macro #include<stdio.h> #define square (x) ((x)*x) int main() { int p; p=square(5); printf(“n Square of 5 is=%d”, p); return 0; }