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
In C, What is the #line used for?
Should I use symbolic names like true and false for boolean constants, or plain 1 and 0?
Is it possible to have a function as a parameter in another function?
Why clrscr is used after variable declaration?
What is the purpose of main( ) in c language?
what is the structure pointer?
Why do we write return 0 in c?
Write a code to achieve inter processor communication (mutual exclusion implementation pseudo code)?
Explain how does flowchart help in writing a program?
Explain the bubble sort algorithm.
What is a node in c?
Explain how can you tell whether two strings are the same?
what are enumerations in C
A collection of data with a given structure for excepting storing and providing on demand data for multiple users a) linked list b) datastructer c) database d) preprocessor
What is the correct declaration of main?