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

Answers were Sorted based on User's Feedback



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

Answer / icywind

#include <stdio.h>
#define SIZE 5
int main(void)
{

int array[] = {100, 32, 22, 500, 21};
int max=0,ii;

for( ii = 0; ii<SIZE; ii++)
{
max = (array[ii]>max)?array[ii]:max;
}
printf("max = %d\n", max);
return 0;
}

Is This Answer Correct ?    7 Yes 1 No

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

Answer / 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

More C Interview Questions

Explain what is a 'null pointer assignment' error? Explain what are bus errors, memory faults, and core dumps?

0 Answers  


What is a pointer variable in c language?

0 Answers  


What is array in c with example?

0 Answers  


Why is not a pointer null after calling free?

0 Answers  


What is the significance of c program algorithms?

0 Answers  


Explain in detail how strset (string handling function works )pls explain it with an example.

1 Answers  


Difference between Shallow copy and Deep copy?

0 Answers  


‘ C’ PROGRAME TO SHOW THE TYPE OF TRANGLE BY ACCEPTING IT’S LENGTH .

0 Answers  


What is a function simple definition?

0 Answers  


In a switch statement, explain what will happen if a break statement is omitted?

0 Answers  


Write a c program to build a heap method using Pointer to function and pointer to structure ?

0 Answers   Wipro,


How do you initialize function pointers? Give an example?

3 Answers  


Categories