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
How can I invoke another program or command and trap its output?
Is c++ based on c?
What is typedf?
if the area was hit by a virus and so the decrease in the population because of death was x/3 and the migration from other places increased a population by 2x then annually it had so many ppl. find our the population in the starting.
What is pointer to pointer in c?
What is unary operator?
What is wild pointer in c?
What are pragmas and what are they good for?
What is the explanation for the dangling pointer in c?
What is a lookup table in c?
write an algorithm to display a square matrix.
What is the size of structure in c?
differentiate built-in functions and user – defined functions.
Explain high-order and low-order bytes.
What is the package for freshers(Non IIT) in amazon(hyderabad). And what is the same for those who are a contract employee.