what are macros?what are its advantages and disadvantages in
c language?

Answer Posted / deepedra kushwaha

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.

The advantage of using macro is the execution speed of the
program fragment. When the actual code snippet is to be
used, it can be substituted by the name of the macro. The
same block of statements, on the other hand, need to be
repeatedly hard coded as and when required.

The disadvantage of the macro is the size of the program.
The reason is, the pre-processor will replace all the macros
in the program by its real definition prior to the
compilation process of the program.
Describe the advantages of using macro.

A macro is a name given to a block of the code which can be
substituted where the code snippet is to be used for more
than once.

- The speed of the execution of the program is the major
advantage of using a macro.

- It saves a lot of time that is spent by the compiler for
invoking / calling the functions.

- It reduces the length of the program.

Is This Answer Correct ?    16 Yes 11 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the main differences between the engines in jet fighters and the engines in jet airliners; which type of engine is the more efficient, and (qualitatively) why?

961


Please if anybody have Vizag Steel Entrance exam papers or atleast Pattern of exam.Then please forward to my email- id: :srikanth.avanthi@gmail.com

1765


MY QUERY IS REGARDING AS/400. I AM FACING A PROBLEM IN UPDATING A PF COZ IT IS GETTING LOCKED SO I USED CHAIN(N) INSTEAD OF ONLY CHAIN.I ALSO TRIED UPDATE(E) ALONG WITH CHAIN(N),ITS NOT GIVING ANY ERROR BUT AT THE SAME TIME NOT UPDATING THE PF

1780


i have got a gre score of 800 in my first attemt and a score of 1080 in the second and i have repoted both the scores.will it effect my chances of getting good university

1682


What is Landscape in Sap BW?

1855


1. Describe a time when you anticipated potential problems and developed Preventive measures.

2008


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

1776


i have applied for junior engg. signal II please send me questions papers for it

1733


Differences between Java and C++? which is faster?

1792


find the net id and host id of the following IPV4 117.34.3.8 and 132.57.8.6

2191


How to Shut-down the system through QTP Script?

1594


how to print a number in character(ex. 123= one twenty three)?

1724


what is the difference between verification and validation

2565


can i clearly know courses under oracle

1647


what is overflow and what are the conditions for which overflow possible?

2367