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
Is swift based on c?
What is a sequential access file?
What is void c?
If a variable is a pointer to a structure, then which operator is used to access data members of the structure through the pointer variable?
What is register variable in c language?
Do you know null pointer?
Using which language Test cases are added in .ptu file of RTRT unit testing???
What standard functions are available to manipulate strings?
explain how do you use macro?
Is fortran faster than c?
Is c still used?
Write a program in "C" to calculate the root of a quadratic equation ax^2+bx+c=0, where the value of a,b & c are known.
Why #include is used in c language?
What is the deal on sprintf_s return value?
Write the Program to reverse a string using pointers.