Find greatest of two numbers using macro
Answers were Sorted based on User's Feedback
Answer / banavathvishnu
#include<stdio.h>
#include<conio.h>
#define Greatest(X,Y) X>Y?X:Y
int main()
{
int x,y;
scanf("%d %d",&x,&y);
printf("%d",Greatest(x,y));
getch();
}
| Is This Answer Correct ? | 91 Yes | 10 No |
Answer / 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 |
Answer / sourav ray
#include<stdio.h>
#include<conio.h>
#define big(a,b) (a>b)?a:b
void main()
{int x,y;
clrscr();
printf("enter the valus of x and y:\n");
scanf("%d%d",&x,&y);
printf("the biggest value is",big(x,y)");
getch();
}
| Is This Answer Correct ? | 16 Yes | 6 No |
How would you print out the data in a binary tree, level by level, starting at the top?
Explain data types & how many data types supported by c?
Mention four important string handling functions in c languages .
The postoder traversal is 7,14,3,55,22,5,17 Then ur Inorder traversal is??? please help me on this
What is New modifiers?
The % symbol has a special use in a printf statement. Explain how would you place this character as part of the output on the screen?
int *a[5] refers to
Explain how do you list a file’s date and time?
Is r written in c?
how we do lcm of two no using c simple if while or for statement
what does exit() do?
How can I display a percentage-done indication that updates itself in place, or show one of those twirling baton progress indicators?