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 memcpy() function?
How can a string be converted to a number?
we need to calculating INCOME TAX for the person. The INCOME TAX is as follows:- First $10000/- of income : 4% tax Next $10000/- of income : 8% tax Next $10000/- of income : 11.5% tax above $10, 00,00/- : 15% tax What is the Solution of this Question ?
Why is c called a structured programming language?
How many keywords are there in c?
Write an algorithm for implementing insertion and deletion operations in a singly linked list using arrays ?
What is the difference between array and pointer in c?
What does %p mean c?
What is a const pointer in c?
What is 'bus error'?
Is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?
Why is C language being considered a middle level language?
What is the size of structure pointer in c?
Can we access the array using a pointer in c language?
What are two dimensional arrays alternatively called as?