1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Biggest of four Nos using Macro..

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

  1. Nageshha

    Nageshha New Member

    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. Nageshha

    Nageshha New Member

    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. shabbir

    shabbir Administrator Staff Member

    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. Nageshha

    Nageshha New Member

    thanks shabbir..
     
  5. imrantechi

    imrantechi New Member

    good one
     
  6. sydneytech

    sydneytech New Member

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

    sydneytech New Member

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

    Because i need this requirement...
     
  8. heena.mca

    heena.mca New Member

    Very good info for me.
     
  9. lead.smart34

    lead.smart34 New Member

  10. crazytolearn57

    crazytolearn57 New Member

  11. aisha.ansari84

    aisha.ansari84 New Member

Share This Page