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

while running a program, i got the msg that press return key to exit.what that mean in C as there are no such options as far i know.

1 Answers   TCS,


write a program to generate address labels using structures?

0 Answers   SJC,


What is #pragma directive?how it is used in the program? what is its advantages and disadvantages?

2 Answers  


about c language

0 Answers  


The __________ attribute is used to announce variables based on definitions of columns in a table?

0 Answers  


the process of defining something in terms of itself is called (or) in C it is possible for the functions to call themselves. A function called a) nested function b) void function c) recursive function d) indifinite function

0 Answers  


Derive the complexity expression for AVL tree?

1 Answers  


write an algorithm which can find the largest number among the given list using binary search ............... this was asked in the interview

2 Answers   Satyam, UNIS, Wipro,


simple c program for 12345 convert 54321 with out using string

7 Answers   TCS,


What is file in c preprocessor?

0 Answers  


How will you allocate memory to double a pointer?

1 Answers  


Is c++ based on c?

0 Answers  


Categories