write a c program to find biggest of 3 number without
relational operator?
Answer Posted / kishore kumar naik p
All above answers are wrong.
For "Manjeeth" answer, it does not work always, for example
a= -8, b = 2;
then
res = (int)(a/b)?a:b;
statement says a as big
res = (int)(-8/2)?-8:2;
res = in(-4)?-8:2
res = -8;
which is wrong.
The other two answers are using relational operators so it
does not answer the question. And finally the answer is
void main()
{
int nNum1, nNum2, nNum3;
int nRes,nSize, nBig;
nSize = sizeof(int) * 8;
printf("\nEnter 3 numbers");
scanf("%d%d%d", &nNum1, &nNum2, &nNum3);
nRes = nNum1 - nNum2;
nRes = nRes >> nSize -1;
nBig = nRes ? nNum1 : nNum2;
nRes = nBig - nNum3;
nRes = nRes >> nSize -1;
nBig = nRes ? nBig : nNum3;
printf("big num = %d", nBig);
}
| Is This Answer Correct ? | 18 Yes | 26 No |
Post New Answer View All Answers
What are the types of arrays in c?
Write an algorithm for implementing insertion and deletion operations in a singly linked list using arrays ?
what are the different storage classes in c?
Is void a keyword in c?
Explain what is wrong in this statement?
How would you use the functions fseek(), freed(), fwrite() and ftell()?
Explain the bubble sort algorithm.
what is the c source code for the below output? 5555555555 4444 4444 333 333 22 22 1 1 22 22 333 333 4444 4444 5555555555
What is array of structure in c?
Synonymous with pointer array a) character array b) ragged array c) multiple array d) none
What is the general form of a C program?
What is methods in c?
How can I handle floating-point exceptions gracefully?
Devise a program that inputs a 3 digit number n and finds out whether the number is prime or not. Find out its factors.
Is c++ based on c?