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 |
while running a program, i got the msg that press return key to exit.what that mean in C as there are no such options as far i know.
write a program to generate address labels using structures?
What is #pragma directive?how it is used in the program? what is its advantages and disadvantages?
about c language
The __________ attribute is used to announce variables based on definitions of columns in a table?
the process of defining something in terms of itself is called (or) in C it is possible for the functions to call themselves. A function called a) nested function b) void function c) recursive function d) indifinite function
Derive the complexity expression for AVL tree?
write an algorithm which can find the largest number among the given list using binary search ............... this was asked in the interview
2 Answers Satyam, UNIS, Wipro,
simple c program for 12345 convert 54321 with out using string
What is file in c preprocessor?
How will you allocate memory to double a pointer?
Is c++ based on c?