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 a program that will print %d in the output screen??

9 Answers   Infosys,


write C code to reverse a string such that if i/p is "abc defg hij klmno pqrs tuv wxyz" and the o/p should be "cba gfed jih onmlk srqp vut zyxw"

2 Answers  


who is the father of C Language?

20 Answers   CTS, UST,


char ch="{'H','I',0};printf("%s",ch);what is output

9 Answers   Accenture,


Tell me when would you use a pointer to a function?

0 Answers  






Explain the array representation of a binary tree in C.

0 Answers   Genpact,


What do you mean by c what are the main characteristics of c language?

0 Answers  


What is variable in c with example?

1 Answers  


Can static variables be declared in a header file?

0 Answers  


What should malloc(0) do? Return a null pointer or a pointer to 0 bytes?

0 Answers  


Taking an example,differentiate b/w loader and linker ?

1 Answers  


consider the following structure: struct num nam{ int no; char name[25]; }; struct num nam n1[]={{12,"Fred"},{15,"Martin"},{8,"Peter"},{11,Nicholas"}}; ..... ..... printf("%d%d",n1[2],no,(*(n1 + 2),no) + 1); What does the above statement print? a.8,9 b.9,9 c.8,8 d.8,unpredictable value

4 Answers   TCS,


Categories