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...

suppose there are five integers write a program to find
larger among them without using if- else

Answer Posted / brindha

#define<stdio.h>
void main()
{
int num, max = 0;
for (i = 0;i < 5; i ++)
{
scanf("Enter next number: %d", &num);
max = findMax(max, num);
}
printf(" MAX is %d", max);
}

int findMax(int x, int y)
{
int mask = 0, result;
mask = (x - y) >> 31;
result = (~mask & x) | (mask & y);
return result;
}

Is This Answer Correct ?    0 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is a constant pointer in C

1183


How are structure passing and returning implemented?

1042


Explain how are 16- and 32-bit numbers stored?

1273


Which built-in library function can be used to match a patter from the string?

1303


Can the sizeof operator be used to tell the size of an array passed to a function?

1118


Can include files be nested? How many levels deep can include files be nested?

1172


how much salary u want ? why u join in our company? your domain is core sector why u prefer software ?

1991


what is the function of pragma directive in c?

1127


Explain what is wrong in this statement?

1125


Can we change the value of static variable in c?

1035


"C" language developed by "Dennis Ritchie" at AT & T. his remarks are a) too general, too abstract b) could deal with only specific problems c) lost generality of BCPL and B restored d) no remarks

1103


What is a lookup table in c?

1124


what are the 10 different models of writing an addition program in C language?

1897


Differentiate between a for loop and a while loop? What are it uses?

1189


Why & is used in c?

1194