Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Find greatest of two numbers using macro

Answer Posted / subbu

While defining macro's for each parameter enclosing brackets
is preferred. For finding out greatest of two numbers better
way writing macro is as below.

#define Greatest(a,b) ((a)>(b))?(a):(b)


If this method not followed, the in the following example
results will be wrong.


#define Product(a,b) (a*b) /* Wrong method */

Bcz if call is done as below

Product(2+3, 4+5) then result will come as (2+3*4+5) = 19
instead of 45.

Is This Answer Correct ?    20 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are pragmas and what are they good for?

952


given post order,in order construct the corresponding binary tree

2752


How do I copy files?

1009


find the sum of two matrices and WAP for it.

1085


What is 1f in c?

2597


what is the format specifier for printing a pointer value?

990


What is linear search?

1095


write a program to create a sparse matrix using dynamic memory allocation.

4857


What is echo in c programming?

979


Can you write the function prototype, definition and mention the other requirements.

1099


Under what circumstances does a name clash occur?

1170


why use "return" statement a) on executing the return statement it immediately transfers the control back to the calling program b) it returns the value present in the parentheses return, to the calling program c) a & b d) none of the above

1042


What are comments and how do you insert it in a C program?

1210


Is c is a procedural language?

1054


Explain what does the characters 'r' and 'w' mean when writing programs that will make use of files?

1224