Write a C program to find biggest of 4 numbers without using relational operators?

Showing Answers 1 - 8 of 8 Answers

VIKAS MAGGO

  • Jan 3rd, 2007
 

int m ;  // any variable

int a,b,c,d ;  // four numbers

m=(a>b && a>c && a>d ) ? a: ((b>c && b>d) ? b : ((c>d)?c : d)) ;

cout<<m; // the greater number ...

  Was this answer useful?  Yes

rahul

  • Jan 3rd, 2007
 

plz read the qn once again ......"without using relational operators....................."

  Was this answer useful?  Yes

Antany

  • Jan 4th, 2007
 

#include <stdio.h>
void main()
{
 int a,b,c,d;
 a=50;
 b=70;
 c=90;
 d=40;


 if(a/b)
 {
  if(a/c)
  {
   if(a/d)
   {
    printf("%d is big ",a);
   }
   else
   {
    printf("%d is big ",d);
   }
  }
  else
  {
   if(c/d)
   {
    printf("%d is big ",c);
   }
   else
   {
    printf("%d is big ",d);
   }

  }
 }
 else
 {
  if(b/c)
  {
   if(b/d)
   {
    printf("%d is big",b);
   }
   else
   {
    printf("%d is big",d);
   }


  }
  else
  {
   if(c/d)
   {
    printf("%d is big",c);
   }
   else
   {
    printf("%d is big",d);
   }
  }
 
 
 }
 
}

  Was this answer useful?  Yes

prashant desai

  • Jan 5th, 2007
 

#include<stdio.h>
main()
{
    int a,b,c;

    c=a^b;

    if (!c)
    {
        printf("both are samen") ;
    }
c=a%b;
if(!(a^c))
{
    printf("second number is greatestn");

}

else
printf("first number is greatestn");

}

Hope this will work for all positive integers

  Was this answer useful?  Yes

main() {
        int a, b, c, d, max;
        printf("Enter numbersn");
        scanf("%d %d %d %d", &a, &b, &c, &d);
        max=a;
        if(b/max)
                max=b;
        if(c/max)
                max=c;
        if(d/max)
                max=d;
        printf("%dn",max);
}

Praveen K

  • Jan 19th, 2007
 

n1,n2,n3,n4

if(n1-n2) && (n1-n3) && (n1-n4)

  Was this answer useful?  Yes

jintojos

  • May 27th, 2008
 

// Find The Largest Of 4 numbers (Only For Positive Numbers) #include #include void main() { int arr[4],arr2[4],i,count; clrscr(); printf("Enter The Numbers :"); for(i=0;i<4;i++) { scanf("%d",&arr[i]); arr2[i]=arr[i]; } do{ if(arr[0]!=0) { count=0; arr[0]--; } if(arr[1]!=0) { count=1; arr[1]--; } if(arr[2]!=0) { count=2; arr[2]--; } if(arr[3]!=0) { count=3; arr[3]--; } }while(arr[0]!=0 || arr[1]!=0 || arr[2]!=0 || arr[3]!=0); printf("The Largest No Is :%d",arr2[count]); getch(); }

  Was this answer useful?  Yes

anshuman singh

  • Jun 12th, 2017
 

Code
  1.  

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions