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


Please Help Members By Posting Answers For Below Questions

WHY IBM MAINFRAME TECHNOLOY IS USED.THOUGH, SINCE ITS INTRODUCTION IT HAS NO MAJOR UPDATATION OR MODIFICATION;BUT STILL IT IS IN DEMAND........WWWWWWWWWWWWWWHHHHHYYYYYYYY????????????

1764


Relative Humidity (RH) is mostly used word in Datacenters, What are the defendents of RH

1541


question no. 4======Give a brief description of the following terms: a) Play head b) Symbol c) Tweening d) ActionScript e) Frame rate f) Library panel g) Masking h) Context – sensitive Property Inspector i) Bandwidth Profiler j) Frame Label

1704


can i learn ad. java without learned core java? java is best or .net is best for summer training?

1724


Can u send me a sample Final year CSE student 'RESUME' for campus placement to following mail id: aspnetworks@gmail.com

3456


Write a program to count the no. of occurrence of word in given string Ex- Ram is good boy. Ram is doing good job. Ram – 2 is – 2 good – 2 boy – 1 doing –1 job – 1

3593


what is b tree

1806


What are daemon Threads?

2081


What is diff b/w TON and BTU for Air conditioner?

1692


anybody, Please send me the NIC(scientific officer/programmer) model questions papers to this mail id:imtiyazahamed14@gmail.com

1650


Calculate the interstage pressure ratio per stage for a two stage compressor if the overall pressure ratio is 10.

1758


What is meant by STL?

2474


what is difference between semaphre and deadlock

1902


Sir, I was recently placed at ITC Infotect. My ctc is 2.46lpa. How much will I get in hand every month? Plssss answer. Thanx in advance.

2384


multithreading??

1720