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 |
What is the output from this program? #include <stdio.h> void do_something(int *thisp, int that) { int the_other; the_other = 5; that = 2 + the_other; *thisp = the_other * that; } int main(void) { int first, second; first = 1; second = 2; do_something(&second, first); printf("%4d%4d\n", first, second); return 0; }
Is c easy to learn?
Explain how can I read and write comma-delimited text?
Print all numbers which has a certain digit in a certain position eg: number=45687 1 number=4 2 number=5 etc
Explain what a Binary Search Tree is.
why program counter is 16 bit?
for questions 14,15,16,17 use the following alternatives:a.int b.char.c.string.d.float
#include<stdio.h> main() { int a=1; int b=0; b=++a + ++a; printf("%d %d",a,b); }
Give a method to count the number of ones in a 32 bit number?
Explain which function in c can be used to append a string to another string?
simple program of graphics and thier outpu display with a want what is out put of graohics in c language
write a method for an array in which it can display the largest n next largest value.