ALLInterview.com :: Home Page            
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Google
   
 
Categories >> Engineering >> Engineering AllOther
 
 


 

 
 Civil Engineering interview questions  Civil Engineering Interview Questions (3011)
 Mechanical Engineering interview questions  Mechanical Engineering Interview Questions (3270)
 Electrical Engineering interview questions  Electrical Engineering Interview Questions (13221)
 Electronics Communications interview questions  Electronics Communications Interview Questions (2348)
 Chemical Engineering interview questions  Chemical Engineering Interview Questions (407)
 Aeronautical Engineering interview questions  Aeronautical Engineering Interview Questions (76)
 Bio Engineering interview questions  Bio Engineering Interview Questions (16)
 Metallurgy interview questions  Metallurgy Interview Questions (79)
 Industrial Engineering interview questions  Industrial Engineering Interview Questions (162)
 Instrumentation interview questions  Instrumentation Interview Questions (2317)
 Automobile Engineering interview questions  Automobile Engineering Interview Questions (104)
 Mechatronics Engineering interview questions  Mechatronics Engineering Interview Questions (38)
 Marine Engineering interview questions  Marine Engineering Interview Questions (43)
 Power Plant Engineering interview questions  Power Plant Engineering Interview Questions (73)
 Engineering AllOther interview questions  Engineering AllOther Interview Questions (1189)
Question
what are macros?what are its advantages and disadvantages in
c language?
 Question Submitted By :: Pravalika
I also faced this Question!!     Rank Answer Posted By  
 
  Re: what are macros?what are its advantages and disadvantages in c language?
Answer
# 1
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 ?    7 Yes 0 No
Ravi Ranjan
 
  Re: what are macros?what are its advantages and disadvantages in c language?
Answer
# 2
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 ?    4 Yes 2 No
Deepedra Kushwaha
 
 
 

 
 
 
Other Engineering AllOther Interview Questions
 
  Question Asked @ Answers
 
Name some band definitions?   1
Briefly describe type of and isvalid operators   1
If you are using C language to implement the heterogeneous linked list, what pointer type will you use?   2
What are the methods available in storing sequential files ?   1
write a program for input is 56 output will be 5+6=10? Infosys 2
what is the print server   1
How many rounds in dell interview process in dell Dell 1
What is a PCB? Country-Club 5
What will be the output of the following program : void main() { int a,b,c; scanf("%1d %2d %3d",&a,&b,&c); printf("Sum=%d",a+b+c); } [NOTE : THE USER INPUT IS :123456 44 544] (a)Sum=480 (b)Sum=594 (c)Sum=589 (d)None of these   2
If a CPU has 20 address lines but MMU does'nt use two of them. OS occupies 20K. No virtual memory is supported. What is the maximum memory available for a user program?   1
Why Mother Board is called Mother Board & not Father Board? Microsoft 8
any one help me how the following program execute main() { int x=5; printf("%d %d %d",x,x<<3,x>>2); } //output : 5 40 1   1
 
For more Engineering AllOther Interview Questions Click Here 
 
 
 
 
 


   
Copyright Policy  |  Terms of Service  |  Articles  |  Site Map  |  RSS Site Map  |  Contact Us
   
Copyright 2013  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  KalAajKal.com