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
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 |
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 |
can u give me the good and very optimised code for a car racing game?
Why can’t we compare structures?
difference between string and array?
What do you mean by c?
Explain how many levels deep can include files be nested?
why arithmetic operation can’t be performed on a void pointer?
write a program to copy a string without using a string?
void main() { int i=5; printf("%d",i++ + ++i); }
Explain what is a 'locale'?
What are the different types of data structures in c?
What is the significance of scope resolution operator?
0 Answers Agilent, ZS Associates,
What is the explanation for cyclic nature of data types in c?