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

am a textile eng. frombut with major of my course including chemical eng, subjects, can i too apply to the co.?

1741


pls i need a help from you friends, is there anybody who can help me out with the question been ask from the USA embassy. i will be going for interview next month pls help me

1590


Hi I am Krushna.I have already applied for PO post in Syndicate Bank.Can anybody send me the sample paper for Syndicate bank PO.

1583


Hi All... PLease send me if anyone have "Information Security Officer" Aptitude papers. Please Mail me at mannusanghi@gmail.com

1677


what are basic step involved in embedded system software development?

2817


wht is difference b/ osi & tcp/ip model

1752


Please. Does someone know how to inicialize tapes in ATL? I need have 100 tapes to init inside the ATL, how is the process to complete this request?

1793


how to find out the name of the users who are currently working starting with the same characters in unix os

1649


I am 2012 pass out b tech student(cse). i have recently started software manual testing class. Is this field is benefitial for me in future?

1856


Whay we use gigabite ethernt

2025


what is advantages and disadvantages of CAT5,CAT5e,CAT6,CAT7,COAXIAL CABLE,FIBER-OPTIC

25879


What is meant by STL?

2490


What is the dewpoint of atmoshperic Air?

1901


WHAT IS DIFFERENT BETWEEN YOU AND OTHER APPLICANT TO GIVE YOU THE JOB

1899


Create an midp application which examines that a phone number which has enters is in the given format * Area code should be one of the following:040,041,050,0400,044

1880