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

In C, What is the #line used for?

2193


Should I use symbolic names like true and false for boolean constants, or plain 1 and 0?

1053


Is it possible to have a function as a parameter in another function?

1070


Why clrscr is used after variable declaration?

1680


What is the purpose of main( ) in c language?

1130


what is the structure pointer?

2120


Why do we write return 0 in c?

1046


Write a code to achieve inter processor communication (mutual exclusion implementation pseudo code)?

1117


Explain how does flowchart help in writing a program?

1111


Explain the bubble sort algorithm.

1051


What is a node in c?

971


Explain how can you tell whether two strings are the same?

1007


what are enumerations in C

1154


A collection of data with a given structure for excepting storing and providing on demand data for multiple users a) linked list b) datastructer c) database d) preprocessor

1082


What is the correct declaration of main?

1206