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 memcpy() function?

1046


How can a string be converted to a number?

965


we need to calculating INCOME TAX for the person. The INCOME TAX is as follows:- First $10000/- of income : 4% tax Next $10000/- of income : 8% tax Next $10000/- of income : 11.5% tax above $10, 00,00/- : 15% tax What is the Solution of this Question ?

1207


Why is c called a structured programming language?

1214


How many keywords are there in c?

1021


Write an algorithm for implementing insertion and deletion operations in a singly linked list using arrays ?

3457


What is the difference between array and pointer in c?

1089


What does %p mean c?

1016


What is a const pointer in c?

1075


What is 'bus error'?

1091


Is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?

1034


Why is C language being considered a middle level language?

1042


What is the size of structure pointer in c?

1017


Can we access the array using a pointer in c language?

995


What are two dimensional arrays alternatively called as?

1133