GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Concepts  >  OOPS
Go To First  |  Previous Question  |  Next Question 
 OOPS  |  Question 14 of 68    Print  
what is the similarities between macro and function?

  
Total Answers and Comments: 8 Last Update: August 07, 2008     Asked by: skr_ymca 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
March 03, 2006 10:42:33   #1  
sandeepyadav        

RE: what is the similarities between macro and functio...
macro are the special function but they consume very less time with respect ot function but there is some restriction in macro you do not use recursion as u can do in function.
 
Is this answer useful? Yes | No
March 04, 2006 22:33:35   #2  
priya        

RE: what is the similarities between macro and functio...
HERE IN MACRO WE CAN DEFINE ANOTHER MACRO LIKE THAT OF FUNCTIONS
 
Is this answer useful? Yes | No
March 09, 2006 06:13:45   #3  
Ranjith        

RE: what is the similarities between macro and functio...

Macro works similar to a function but it's execution time is faster than function. Also macro simply substitutes the value without performing calculatons where as function does calculations. The following example describes the difference between macro and function:

Macro:

#define sq(x) x*x

if you call sq(5+5) the result will be 35 becos macro directly substitutes the value. i.e in this case 5+5*5+5 35.

Function:

int sq(x)

{

return x*x;

}

if you call sq(5+5) now the result will be 100 because function calculates the argument value (if it has some calculations) and passes to the operation stack. i.e in this case sq(5+5) will become sq(10) before passing to return x*x.

Hope this clears. Please let me know if anybody know more about this


 
Is this answer useful? Yes | No
March 10, 2006 05:33:30   #4  
sandeep kuamr rao        

RE: what is the similarities between macro and functio...

hello friend

thanks for ur sweet efforts.

but i m sorry to say that i also knows what r the differences between macro and function............

actually i want to know what r the SIMILARITIES between macro and function?

i u know plz plz let me know also.

have a nice day..

bye.


 
Is this answer useful? Yes | No
March 10, 2006 05:33:55   #5  
vijay        

RE: what is the similarities between macro and functio...

now how do you declare a macro in vb.net

functions are declared as

public function functionname() as datatype

end function

what about a macro


 
Is this answer useful? Yes | No
June 12, 2006 22:16:25   #6  
aptuz Member Since: June 2006   Contribution: 1    

RE: what is the similarities between macro and functio...

As Priya says from her straight shoot line that makes sense.

A MACRO CAN CALL ANOTHER MACRO WITH IN ITS DEFINITION PRETTY MUCH LIKE IN FUNCTIONS.

#define sq(x) x * x; // finds square of 'x'
#define cu(x) sq(x) * x; // finds cube of 'x'

Here a macro calls another macro which is strticly possible. The similarity in functions could look like this.

int sq(int x) { return ( x * x ); }
int cu(int x) { return ( sq ( x ) * x ); }

would be a valid equivalent set of statements that could do the same functionality as that of above macros.

Hope tha HELPS!!!


 
Is this answer useful? Yes | No
November 10, 2006 10:07:22   #7  
Megha        

RE: what is the similarities between macro and functio...

Helo Ranjith....Thanx for explaining the difference b/w a macro and a function.......


 
Is this answer useful? Yes | No
August 06, 2008 12:11:45   #8  
VCCoder Member Since: August 2008   Contribution: 4    

RE: what is the similarities between macro and function?
We can pass arguments into the macro as well as function.
We can say that a Macro is smilar to a global function

 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape