Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/articles/c-tutorials/)
-   -   Biggest of four Nos using Macro.. (http://www.go4expert.com/articles/biggest-four-nos-using-macro-t474/)

 Nageshha 19Oct2005 11:44

Biggest of four Nos using Macro..

Code: C

`#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();}`

 Nageshha 19Oct2005 11:49

Re: Biggest of four Nos using Macro..

hey guys ':' followed by '(' is acting as sad smiley so pls whereever u se smiley replace it by ':' follwed by '(' ...

Thanks
Nagesh

 shabbir 19Oct2005 13:04

Re: Biggest of four Nos using Macro..

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(); }```

 Nageshha 19Oct2005 13:52

Re: Biggest of four Nos using Macro..

thanks shabbir..

 imrantechi 13Feb2008 14:17

Re: Biggest of four Nos using Macro..

good one

 sydneytech 13Feb2008 17:09

Re: Biggest of four Nos using Macro..

Can you make it generic for any number ( not only for four).

 sydneytech 13Feb2008 17:09

Re: Biggest of four Nos using Macro..

Just try and you can do taking a sort of template not exactly template.

Because i need this requirement...

 heena.mca 17Feb2008 12:40

Re: Biggest of four Nos using Macro..

Very good info for me.

Re: Biggest of four Nos using Macro..

good one

 crazytolearn57 26Feb2008 18:35

Re: Biggest of four Nos using Macro..

good one

 aisha.ansari84 5Mar2008 18:42

Re: Biggest of four Nos using Macro..

nice

 All times are GMT +5.5. The time now is 17:29.