suppose there are five integers write a program to find
larger among them without using if- else

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

A routine usually part of the operation system that loads a program into memory prior to execution a) linker b) loader c) preprocessor d) compiler

614


Write a function which takes as parameters one regular expression(only ? and * are the special characters) and a string and returns whether the string matched the regular expression.

640


What are preprocessor directives?

662


What is static identifier?

692


How many types of operators are there in c?

609






What is putchar() function?

623


write a program in C that prompts the user for today's date,tomorrow's date and display the results.Use structures for today's date,tomorrow's date and an array to hold the days for each month of the year.

4971


An application package has been provided to you without any documents for the following application. The application needs to be tested. How will you proceed?

657


Tell me the use of bit field in c language?

615


How do I read the arrow keys? What about function keys?

606


Write a program to replace n bits from the position p of the bit representation of an inputted character x with the one's complement. Method invertBit takes 3 parameters x as input character, p as position and n as the number of positions from p. Replace n bits from pth position in 8 bit character x. Then return the characters by inverting the bits.

3681


What are the back slash character constants or escape sequence charactersavailable in c?

676


Why c is known as a mother language?

627


How does placing some code lines between the comment symbol help in debugging the code?

534


int i=10; printf("%d %d %d", i, i=20, i);

998