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
find the output? void r(int a[],int c, int n) { if(c>n) { a[c]=a[c]+c; r(a,++c,n); r(a,++c,n); } } int main() { int i,a[5]={0}; r(a,0,5); for(i=0;i<5;i++) printf("\n %d",a[i]); getch(); }
I need a sort of an approximate strcmp routine?
State the difference between x3 and x[3].
any "C" function by default returns an a) int value b) float value c) char value d) a & b
What are the 4 types of organizational structures?
How to draw the flowchart for structure programs?
Can you subtract pointers from each other? Why would you?
Do you know the use of 'auto' keyword?
Write a C Program That Will Count The Number Of Even And Odd Integers In A Set using while loop
If one class contains another class as a member, in what order are the two class constructors called a) Constructor for the member class is called first b) Constructor for the member class is called second c) Only one of the constructors is called d) all of the above
Why is sprintf unsafe?
Write a program to print ASCII code for a given digit.
Explain how can I read and write comma-delimited text?
What are qualifiers in c?
Why do some versions of toupper act strangely if given an upper-case letter?