Write a C program to find the smallest of three integers,
without using any of the comparision operators.
Answer Posted / jb
The trick is to use the sign bit
void main() {
int a = 1;
int b = 2;
int c = 3;
int maximum = max(max(a,b),c);
}
int max(int a, int b) {
int diff = a - b;
int sign = (diff >> 31) & 0x1;
return a - (sign * diff);
}
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is scanf () in c?
A collection of functions,calls,subroutines or other data a) library b) header files c) set of files d) textfiles
What is a floating point in c?
What are the advantages of using new operator as compared to the function malloc ()?
Why is python slower than c?
the real constant in c can be expressed in which of the following forms a) fractional form only b) exponential form only c) ascii form only d) both a and b
What is the difference between %d and %i?
What is #include in c?
What is a structure and why it is used?
What is 2 d array in c?
What is volatile keyword in c?
What do you mean by a local block?
What are the three constants used in c?
Explain what is the general form of a c program?
in iso what are the common technological language?