Basic computer course, C programming language, Education, Engineering Course, Engineering Courses, Maths Coaching, online computer coaching, PGDCA course coaching, programming course, school computer coaching, training, Uncategorized, Web Design course

What is macro in c? tccicomputercoaching.com

Macro processor that is used automatically by the compiler to transform your program before actual compilation. It is called a macro processor because it allows you to define macros, which are brief abbreviations for longer constructs.

A macro is a segment of code which is replaced by the value of macro. Macro is defined by #define directive.

macro in c

Macros in C are string replacements commonly used to define constants.

The function-like macro looks like function call. For example:

For example:-

1. #define MAX 1000

It sets the value of identifier MAX to 1000 and whenever you want to use 1000 in your program you can use MAX instead of writing 1000.

2. Argumented macro substitution (this permits us to define more complex and more useful forms of replacements):-

It takes the form:-

#define identifier (f1, f2,.., fn) string

For example, #define CUBE(x) (x*x*x)

If the following statement appear in the prog.-

Volume = CUBE (side);

Then the pre-processor will expand this statement to:

Volume = (side*side*side);

To learn more about C Programming Language

Call us @ 9825618292

Visit us @ http://www.tccicomputervoaching.com

 

Leave a comment