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 |
i want to make a program in which we use input having four digits(4321) and get output its reciprocal(1234).
How to declare a variable?
what is the syallabus of computer science students in group- 1?
What is a macro, and explain how do you use it?
Q-1: Create a structure to specify data on students given below: Roll number, Name, Department, Course, Year of joining Assume that there are not more than 450 students in the college.
what is a function prototype?
Program to find the value of e raised to power x using while loop
What is a pointer?
what is the difference between postfix and prefix unary increment operators?
wt is diference between int and int pointer as same as float and float pointer and char and char pointer
Can a variable be both static and volatile in c?
int main() { int *p=new int; *p=10; del p; cout<<*p; *p= 60; cout<<*p; } what will be the output & why?