# Biggest of four Nos using Macro..

Discussion in 'C' started by Nageshha, Oct 19, 2005.

1. ### NageshhaNew Member

Joined:
Oct 18, 2005
Messages:
9
0
Trophy Points:
0
Code:
```#define f(a,b,c,d) (a>b?(a>c?(a>d?a:d):(c>d?c:d)):(b>c?(b>d?b:d):(c>d?c:d)))

#include<stdio.h>
#include<conio.h>

void main()
{
int a, b, c, d, k;
clrscr();
printf("Enter the value of a, b, c, d\n");
scanf("%d%d%d%d", &a, &b, &c, &d);
printf("\n%d\n", f(a, b, c, d));
getch();
}```

2. ### NageshhaNew Member

Joined:
Oct 18, 2005
Messages:
9
0
Trophy Points:
0
hey guys ':' followed by '(' is acting as sad smiley so pls whereever u se smiley replace it by ':' follwed by '(' ...

Thanks
Nagesh

Last edited: Oct 19, 2005
3. ### shabbirAdministratorStaff Member

Joined:
Jul 12, 2004
Messages:
15,292
365
Trophy Points:
83
I have edited that for no smiley as well as proper formating. Here is the code snippet again for you

Code:
```#define f(a,b,c,d) (a>b?(a>c?(a>d?a:d):(c>d?c:d)):(b>c?(b>d?b:d):(c>d?c:d)))

#include<stdio.h>
#include<conio.h>

void main()
{
int a, b, c, d, k;
clrscr();
printf("Enter the value of a, b, c, d\n");
scanf("%d%d%d%d", &a, &b, &c, &d);
printf("\n%d\n", f(a, b, c, d));
getch();
}```

4. ### NageshhaNew Member

Joined:
Oct 18, 2005
Messages:
9
0
Trophy Points:
0
thanks shabbir..

5. ### imrantechiNew Member

Joined:
Feb 12, 2008
Messages:
116
4
Trophy Points:
0
good one

6. ### sydneytechNew Member

Joined:
Feb 6, 2008
Messages:
12
0
Trophy Points:
0
Can you make it generic for any number ( not only for four).

7. ### sydneytechNew Member

Joined:
Feb 6, 2008
Messages:
12
0
Trophy Points:
0
Just try and you can do taking a sort of template not exactly template.

Because i need this requirement...

8. ### heena.mcaNew Member

Joined:
Feb 14, 2008
Messages:
20
0
Trophy Points:
0
Very good info for me.

9. ### lead.smart34New Member

Joined:
Feb 14, 2008
Messages:
77
0
Trophy Points:
0
good one

10. ### crazytolearn57New Member

Joined:
Feb 14, 2008
Messages:
48
0
Trophy Points:
0
good one

Joined:
Feb 13, 2008
Messages:
82