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 is the 'named constructor idiom'?

1031


How do I swap bytes?

1022


What is array of structure in c programming?

1236


What is malloc and calloc?

1003


When reallocating memory if any other pointers point into the same piece of memory do you have to readjust these other pointers or do they get readjusted automatically?

1208


What are runtime error?

1077


How does #define work?

1009


What is c basic?

1122


Do you know the purpose of 'register' keyword?

966


What is identifiers in c with examples?

1117


Describe the difference between = and == symbols in c programming?

1294


Tell us the use of fflush() function in c language?

1083


What is sizeof int in c?

1002


what is the c source code for the below output? 10 10 10 10 10 10 10 10 10 10 9 9 7 6 6 6 6 6 6 9 7 5 9 7 3 2 2 5 9 7 3 1 5 9 7 3 5 9 7 4 4 4 4 5 9 7 8 8 8 8 8 8 8 8 9

1780


Define C in your own Language.

1032