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
what is a constant pointer in C
How are structure passing and returning implemented?
Explain how are 16- and 32-bit numbers stored?
Which built-in library function can be used to match a patter from the string?
Can the sizeof operator be used to tell the size of an array passed to a function?
Can include files be nested? How many levels deep can include files be nested?
how much salary u want ? why u join in our company? your domain is core sector why u prefer software ?
what is the function of pragma directive in c?
Explain what is wrong in this statement?
Can we change the value of static variable in c?
"C" language developed by "Dennis Ritchie" at AT & T. his remarks are a) too general, too abstract b) could deal with only specific problems c) lost generality of BCPL and B restored d) no remarks
What is a lookup table in c?
what are the 10 different models of writing an addition program in C language?
Differentiate between a for loop and a while loop? What are it uses?
Why & is used in c?