what are macros?what are its advantages and disadvantages in
c language?
Answer Posted / ravi ranjan
A macro is a name given to a block of C statements as a
pre-processor directive. Being a pre-processor, the block of
code is communicated to the compiler before entering into
the actual coding (main () function). A macro is defined
with the preprocessor directive, #define.
Like::: #define A 10
#define SUM(x,y) ((x) + (y))
Advantages :::
1.Symbolic constants are evaluated by the PRE-processor,
i.e. they are re-written as literal values, not as
variables. this has some nice side-effects that you can do
using symbolic defines eg. macros and functions inside them.
run-time access to symbolic constants should be
significantly faster than access to variables.
opposite to that, variables (and constants) are evaluated by
the processor (compiler).
2. It is easy to modify the value of the constant
variable,since we have to change the value at the macro
defintion only
DisAdvantages:::
1. Macros are not useful when the function definitions are
Big and when the function is used many number of times.
| Is This Answer Correct ? | 52 Yes | 14 No |
Post New Answer View All Answers
i have passed my gRaduation in BCA and now im looking for post graduation from Germany, i haver passed my ielts wth 6 band, nw plz tell me some question that wll ambessay ask
How does an aeroplane stay airborne and how can some aeroplanes fly upside down?
How will I MOve Comp-1 variable into next variable without using Move statement?
what is the program to find out the smallest word in a sentence? like if the sentence is : this is my room. then out put will be : is
plz send me how to overhauling of freon bitzer semi receprocal comprassors with available video
explain various object oriented programming fetures
Just a one miniute topics in English?
Hi, I am preparing for Assistant Motor Vehicle Inspector (AMVI) exam.If any body having old question papers please send.My mail id is siyadndd@gmail.com
I want old SBI question papers plzzzzzzzzz
what is c dot
Given a number (N), program to check whether its binary form has periodic or not
safety valve calculation?
how to find out the name of the users who are currently working starting with the same characters in unix os
how am i supposed to convert a class program in C++ to Matlab? Do i also need to make classes in matlab too or I can do it without making classes???Can somebody help....
write program which accept information about 5 student & display same information according to ascending order of their name??