Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What is the g value paradox?

1118


What is clrscr ()?

1069


Explain what will the preprocessor do for a program?

1019


What is external variable in c?

1023


Explain what is the difference between far and near ?

1063


Hai sir, I had planned to write the NIC scientific engineer exam , plz post the sample question......

2148


What is context in c?

892


a formula,a series of steps,or well defined set of rules for solving a problem a) algorithem b) program c) erdiagram d) compiler

1042


How can I recover the file name given an open stream?

970


What is calloc malloc realloc in c?

1022


In C language, the variables NAME, name, and Name are all the same. TRUE or FALSE?

1185


What does the characters “r” and “w” mean when writing programs that will make use of files?

1436


Is sizeof a keyword in c?

923


write a program for the normal snake games find in most of the mobiles.

2225


what are the program that using a two dimensional array that list the odd numbers and even numbers separately in a given 10 inputs values

1661