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
what do you mean by a p-code?
Hi dost here Alok Kumar please send question pattern for NIC at godinall.kumar1@gmail.com or alok.iitb07@gmail.com
what is 16kHz use in GSM
in single linked list , each node contains data and address of next node. if middle of list the node is damaged/crashed then how to find where the link is failed and how to get the all the data which is stored after the crashed node?
C++ PROGRAM FOR FIBONACCI SERIES USING COPY CONSTRUCTER
compare the conditional operator with if-else-if statement.
What is the meaning of int p(char*a);
why this for loop doesn't work . int i; for(i=2;i=0;i--) { cout<
there are 50 users in a network, one system is virus affected , how to find that virus affected system?
Explain work?
draw the diagram of double earthing
why there is a collision in switch
can i get some win vista notes
i want techical questions on c and java with code part
hey,,,hi have taken an emergency date of 21st july...i was continuously checking for dates n i was not able to get a normal date n my school is starting from 8th of september...so plz tell me can i get a rejection based on this, that i have taken an emergency date?????