• Skip to main content
  • Skip to primary sidebar
  • Skip to secondary sidebar
  • Skip to footer

Computer Notes

Library
    • Computer Fundamental
    • Computer Memory
    • DBMS Tutorial
    • Operating System
    • Computer Networking
    • C Programming
    • C++ Programming
    • Java Programming
    • C# Programming
    • SQL Tutorial
    • Management Tutorial
    • Computer Graphics
    • Compiler Design
    • Style Sheet
    • JavaScript Tutorial
    • Html Tutorial
    • Wordpress Tutorial
    • Python Tutorial
    • PHP Tutorial
    • JSP Tutorial
    • AngularJS Tutorial
    • Data Structures
    • E Commerce Tutorial
    • Visual Basic
    • Structs2 Tutorial
    • Digital Electronics
    • Internet Terms
    • Servlet Tutorial
    • Software Engineering
    • Interviews Questions
    • Basic Terms
    • Troubleshooting
Menu

Header Right

Home » C++ » Oops » What Do you Mean By Preprocessors
Next →
← Prev

What Do you Mean By Preprocessors

By Dinesh Thakur

Preprocessors are the Source of our Program those are Executed whey they are passing to Compiler and Preprocessors are always executed at the Time of Compilations. Preprocessors provide many features called Preprocessor directives and Each Preprocessor is declared with # symbol and This Directive must be written before a main program.

Programs starts with code line #include <stdio.h>. Here, the directive #include is a preprocessor command. All preprocessor commands start with the sign#. The command given above directs the compiler to include the header file <stdio.h> (standard input/output header file) from C Standard Library in this program. Standard input is used to denote input from keyboard and standard output is used to indicate display on the monitor connected to the computer. A program that requires standard input and standard output must include the header file <stdio.h> as it has been done in Program. The header file <stdio. h> also contains many other functions that help in formatting the input/output of a program as well.

More than one header file from C Standard Library may be included in a program if these are required for the manipulation of data of the program. For example, if you want to carry out evaluation of mathematical functions such as square-root, sine or cosine of angles, log(x), or evaluation of exponential functions, you must include the header file <math.h>.This header file has the procedural software for evaluations of many such functions. For including more than one header files in a program, these should be written in successive lines. Only one header file is written in one line. The name of each header file, if it belongs to the C Standard Library, is enclosed between the angular brackets < >. The names end with extension (.h) as illustrated below.

#include <stdio.h>

#include <math.h>

The Preprocessor’s are Used For Two Purposes either they are used as Macros and either they are used as File inclusions like Many Times we write #include this is also a Preprocessor directive which is used for Including the Contents of a File Like iostream.h and either conio.h or any other File But the Macros are Also Called as Small Programs or The Macros are Used for Giving a Short names to Long Statements and Long Keywords and a user can Specify his own names to a keyword of c language

Macros are always define by using a #define Statement and For Defining our Own Macro First we have to specify our name for a Macro then we writes the Statements those are to be Executed When a Macro is Called or When that Name is used in any where in a program For Defining a Macro We have to Write Like This

  #define Integer int

Now we can use Integer instead of int .But Always Remember we are not Replacing a Word with our Words We are just Giving a another name to a built in Keyword

In Macro we can also write any Statements and any Expression for Example

  #define Max 100

  #define or ||

  #define Sqr(x) x*x

These are the Some Examples of Writing a Macro in the First Macro we defines a Max Word Wherever we use Max then Compiler will treat as 100 and Second Macro is or name to a or Symbol means Now Whether We can use a or Symbol and Instead of Putting a Symbol we can and either write a or word. Third Macro defines a Sqr(x) Whenever we writes Sqr with a Number then this will gives us a Square of a number etc.

There are many Conditional Compilation Macros those are used for Performing operations on Macros Like Checking the Value of Macro and To Check Whether a Macro is Defined or not

The Various Condition Compilation Macros are as follows:-

1. #ifdef:- This is used for Checking either a Macro with a Specified Name is Defined or not .Or it checks Whether a Macro is defined For use.

2. #undef:- This is Used for Un-defining a Macro. Or if we want to remove the definition of a Macro from our Program .then we can use #undef.

3. #ifndef:- This Condition Compilation is used for Check either a Macro is not Defined if a Macro really not defined then this will gives us true or if a Macro is defined then this will gives us false

4. #if :- #if condition Compilation Macro if used for Checking a value of Macro that is defined in a Macro definition or it checks whether an Expression evaluates to nonzero or not and always Remember Every #if Macro is must be Closed with the help of #endif

5. #else:- Used the Condition of First #if Macro is False . This is Similar to simple If else but Difference is that if –Else operates on value of Variable but #if performs or it either checks the Value of a Macro and this will be Executed When no Match of Macro Value is to be found same as else statement

6. #else if:– This Directive is used when we wants to Check one more Condition upon the Macros When #if is False then the Compiler will check another value that is defined in #else if Directive and also Every #elseif directive must be end with #endif

Next →
← Prev
Like/Subscribe us for latest updates     

About Dinesh Thakur
Dinesh ThakurDinesh Thakur holds an B.C.A, MCDBA, MCSD certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps.

Dinesh Thakur is a Freelance Writer who helps different clients from all over the globe. Dinesh has written over 500+ blogs, 30+ eBooks, and 10000+ Posts for all types of clients.


For any type of query or something that you think is missing, please feel free to Contact us.


Primary Sidebar

C++ Tutorials

C++ Tutorials

  • C++ - Data Types
  • C++ - Operators Types
  • C++ - CPP Program Structure
  • C++ - Conditional Statements
  • C++ - Loop
  • C++ - do-While Loop
  • C++ - Control Statements
  • C++ - Tokens
  • C++ - Jump Statements
  • C++ - Expressions
  • C++ - Constants
  • C++ - Character Set
  • C++ - Iteration Statements
  • C++ - I/O Statements
  • C++ - String
  • C++ - Manipulators

C++ Operator

  • C++ - Input/Output Operator
  • C++ - Operator Overloading

C++ Functions

  • C++ - Functions
  • C++ - Member Functions
  • C++ - Returning Object from Function
  • C++ - Call by Value Vs Reference
  • C++ - Friend Function
  • C++ - Virtual Function
  • C++ - Inline Function
  • C++ - Static Data Members
  • C++ - Static Member Functions

C++ Array & Pointer

  • C++ - Array
  • C++ - Array of Objects
  • C++ - Arrays as Class Members
  • C++ - Vector
  • C++ - Pointer
  • C++ - 'this' Pointer

C++ Classes & Objects

  • C++ - Class
  • C++ - Program Structure With Classes
  • C++ - OOP’s
  • C++ - Objects as Function Arguments
  • C++ - Procedure Vs OOL
  • C++ - Object Vs Class
  • C++ - Creating Objects
  • C++ - Constructors
  • C++ - Copy Constructor
  • C++ - Constructor Overloading
  • C++ - Destructor
  • C++ - Polymorphism
  • C++ - Virtual Base Class
  • C++ - Encapsulation

C++ Inheritance

  • C++ - Inheritance
  • C++ - Multiple Inheritance
  • C++ - Hybrid Inheritance
  • C++ - Abstraction
  • C++ - Overloading

C++ Exception Handling

  • C++ - Exception Handling
  • C++ - Templates
  • C++ - Standard Template Library

C++ Data Structure

  • C++ - Link List

C++ Programs

  • C++ Program for Electricity Bill
  • C++ Program for Multiply Matrices
  • C++ Program for Arithmetic Operators
  • C++ Program For Matrices
  • C++ Program for Constructor
  • C++ Program Verify Number
  • C++ Program Array Of Structure
  • C++ Program to find Average Marks
  • C++ Program Add And Subtract Matrices
  • C++ Program Menu Driven
  • C++ Program To Simple Interest
  • C++ Program To Find Average
  • C++ program exit()
  • C++ Program Using Array Of Objects
  • C++ Program Private Member Function
  • C++ Program To Reverse A String
  • C++ Program to Operator Overloading

Other Links

  • C++ - PDF Version

Footer

Basic Course

  • Computer Fundamental
  • Computer Networking
  • Operating System
  • Database System
  • Computer Graphics
  • Management System
  • Software Engineering
  • Digital Electronics
  • Electronic Commerce
  • Compiler Design
  • Troubleshooting

Programming

  • Java Programming
  • Structured Query (SQL)
  • C Programming
  • C++ Programming
  • Visual Basic
  • Data Structures
  • Struts 2
  • Java Servlet
  • C# Programming
  • Basic Terms
  • Interviews

World Wide Web

  • Internet
  • Java Script
  • HTML Language
  • Cascading Style Sheet
  • Java Server Pages
  • Wordpress
  • PHP
  • Python Tutorial
  • AngularJS
  • Troubleshooting

 About Us |  Contact Us |  FAQ

Dinesh Thakur is a Technology Columinist and founder of Computer Notes.

Copyright © 2025. All Rights Reserved.

APPLY FOR ONLINE JOB IN BIGGEST CRYPTO COMPANIES
APPLY NOW