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

5S training documents

2766


c ka base kya hota hai? what is communication?

4983


Please send me the ongc old question papers

2835


assemblies in .net

1801


Hi manikandhan, my name is ruby. Can u pls forward the conduct/character certificate on my Id. ruby_cse07@yahoo.co.in what details shall i require for this certificate. pls help me out with this..its really very urgent.. let me know soon bcoz my interview is on 19th septemper in mumbai...

1897


I have applied for the post of Section Engineer. plz anyone send me the previous question paper. i did my engineering in Information Technology.

1742


why view is created in database

1467


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

1534


How many VLANs are supported on a single switch

1613


Which is better field cad/cam in mechanical or film editing/animation is better salary wise?

1644


Why the secondary ip address of interface is not advertising in IGP cloud?

4292


How many of 14 digit numbers we can make with 1,2,3,4,5 that are divisible by 4. Repetitions allowed.

2139


why we select you?

1998


I have Job A and Job B in jcl. I want to trigger Job B from Job A. Please advise.

1752


How to Define the defect density?

1734