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 is break statement?
What is malloc return c?
Explain the difference between getch() and getche() in c?
What is the hardest programming language?
How do I copy files?
How can I trap or ignore keyboard interrupts like control-c?
Can the size of an array be declared at runtime?
can anyone suggest some site name..where i can get some good data structure puzzles???
What is the explanation for the dangling pointer in c?
Is file a keyword in c?
Is it possible to initialize a variable at the time it was declared?
Explain data types & how many data types supported by c?
Why c is faster than c++?
Can we increase size of array in c?
please can any one suggest me best useful video tutorials on c i am science graduate.please help me.u can email me to sas29@in.com