Program to find largest of three numbers without using comparsion operator?

Answers were Sorted based on User's Feedback



Program to find largest of three numbers without using comparsion operator?..

Answer / a.naga tirupathi rao

#include <stdio.h>
#include <conio.h>
main()
{
int a[i],sum=0,i,j;
for(i=1;i<=3;i++)
{
scanf("%d",&a[i]);
sum=sum+a[i];
}
for(j=sum;j<=sum;j--)
{
for(i=1;i<=3;i++)
{
if(j==a[i])
{
printf("%d is biggest",j);
break;
}
}
}
getch();
}

Is This Answer Correct ?    4 Yes 1 No

Program to find largest of three numbers without using comparsion operator?..

Answer / sanjay bhosale

Both programs mentioned above produce wrong results when some numbers are positive and others are negatives.

Is This Answer Correct ?    0 Yes 0 No

Program to find largest of three numbers without using comparsion operator?..

Answer / arunslb123

ct=0;
while(var1 && var2 && var3){
var1++;
var2++;
var3++;
ct--;
}
printf("%d",ct);

could u pls explain this

Is This Answer Correct ?    5 Yes 6 No

Post New Answer

More C Interview Questions

write an algorithm which can find the largest number among the given list using binary search ............... this was asked in the interview

2 Answers   Satyam, UNIS, Wipro,


What is variable declaration and definition in c?

0 Answers  


what are the languages used in c#?

3 Answers   Infosys,


Explain what is a program flowchart and explain how does it help in writing a program?

0 Answers  


How can I avoid the abort, retry, fail messages?

0 Answers  


What is the use of extern in c?

0 Answers  


What do you understand by normalization of pointers?

0 Answers  


Explain how do you override a defined macro?

0 Answers  


main() { static char *s[]={"black","white","yellow","voilet"}; char **ptr[]={s+3,s+2,s+1,s}, ***p; p=ptr; **++p; printf("%s",*--*++p+3); }

1 Answers  


i want to make a program in which we use input having four digits(4321) and get output its reciprocal(1234).

1 Answers  


Write a small C program to determine whether a machine's type is little-endian or big-endian.

5 Answers   nvidia,


How many types of operators are there in c?

0 Answers  


Categories