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
how will u recieve an std idoc from sendor->reciever
How Main()is called by opreting system?
which is the better form java or .net?exactly when we have to choose particcular 1 among them?
draw diagram of earthings
write a c program which accept input as:Anu.B.Kapur and give out as:Kapur.A.B using pointers
i m a student of 4th year ,i m unable to get the embassy appointment dates , and it details.............please help any body.My id=john_searching143@yahoo.com
funtionalities of loadining and linking
Write a regular expression for "Capgemini Services Pvt.Ltd"
List three things you can do with the files you create by recording your voice on your computer
how do we calculate physical address if logical address is given in the question?
I am going to HAL Online test for Computer Science. Can you please mail me the model question papers ?
hai im going to face ibps SO IT officers grade 1 interview. if anyone had an idea plz tel me expected and experienced questions and mail to anusha_k_anu@yahoo.com
Can a generic class extend another generic class??
I have Job A and Job B in jcl. I want to trigger Job B from Job A. Please advise.
difference between java programming and c programming??