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 data structure in c language?
What are the different types of C instructions?
Should I learn c before c++?
What is extern variable in c with example?
What happens if header file is included twice?
Explain pointers in c programming?
Is register a keyword in c?
What is c language & why it is used?
What is meant by initialization and how we initialize a variable?
What is the use of bit field?
Are the expressions * ptr ++ and ++ * ptr same?
What should malloc() do?
What is the difference between printf and scanf in c?
program to find out date after adding 31 days to a date in the month of febraury also consider the leap year
For what purpose null pointer used?