suppose there are five integers write a program to find
larger among them without using if- else
Answers were Sorted based on User's Feedback
Answer / icywind
#include <stdio.h>
#define SIZE 5
int main(void)
{
int array[] = {100, 32, 22, 500, 21};
int max=0,ii;
for( ii = 0; ii<SIZE; ii++)
{
max = (array[ii]>max)?array[ii]:max;
}
printf("max = %d\n", max);
return 0;
}
| Is This Answer Correct ? | 7 Yes | 1 No |
Answer / 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 |
Explain what is a 'null pointer assignment' error? Explain what are bus errors, memory faults, and core dumps?
What is a pointer variable in c language?
What is array in c with example?
Why is not a pointer null after calling free?
What is the significance of c program algorithms?
Explain in detail how strset (string handling function works )pls explain it with an example.
Difference between Shallow copy and Deep copy?
‘ C’ PROGRAME TO SHOW THE TYPE OF TRANGLE BY ACCEPTING IT’S LENGTH .
What is a function simple definition?
In a switch statement, explain what will happen if a break statement is omitted?
Write a c program to build a heap method using Pointer to function and pointer to structure ?
How do you initialize function pointers? Give an example?