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
What is the use of void pointer and null pointer in c language?
Explain what is gets() function?
What is the use of bit field?
What is the heap in c?
What are the different types of errors?
The performance of an operation in several steps with each step using the output of the preceding step a) recursion b) search c) call by value d) call by reference
What are the types of type specifiers?
what is event driven software and what is procedural driven software?
write a program to rearrange the array such way that all even elements should come first and next come odd
Explain what is the difference between text files and binary files?
What is binary tree in c?
What is data structure in c language?
Explain what are the different file extensions involved when programming in c?
What is a structural principle?
What is the importance of c in your views?