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 #line used for?
typedef struct{ char *; nodeptr next; } * nodeptr ; What does nodeptr stand for?
What is difference between far and near pointers?
What are the benefits of c language?
What is #include called?
All technical questions
How can I read/write structures from/to data files?
Where are c variables stored in memory?
Sir,please help me out with the code of this question. Write an interactive C program that will encode or decode multiple lines of text. Store the encoded text within a data file, so that it can be retrieved and decoded at any time. The program should include the following features: (a) Enter text from the keyboard, encode the text and store the encoded text in a data file. (b) Retrieve the encoded text and display it in its encoded form. (c) Retrieve the encoded text, decode it and then display the decoded text. (d) End the computation. Test the program using several lines of text of your choice.
Write a C++ program to generate 10 integer numbers between - 1000 and 1000, then store the summation of the odd positive numbers in variable call it sum_pos, then find the maximum digit in this variable regardless of its digits length.
Write a Program to accept different goods with the number, price and date of purchase and display them
Why are some ANSI/ISO Standard library routines showing up as undefined, even though I've got an ANSI compiler?
What is pointer in c?
can anyone please tell about the nested interrupts?
What is a built-in function in C?