answersLogoWhite

0


Best Answer

int a, b, c, d, max, min;

scanf("%d%d%d%d",&a, &b, &c, &d);

(a>b)?(max=a,min=b):(max=b,min=a);

(c>d)?(a=c,b=d):(a=d,b=c);

max=(a>max)?a:max;

min=(b<min)?b:min;

printf("%d %d\n", max, min);

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you find the largest and the smallest values among 4 numbers using conditional operators?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Largest of 3 numbers without using conditional or relational operators?

void main() { int a = 5; int b = 7; int c = 2; int res; res = (int)(a/b)?a:b; res = (int)(res/c)?res:c; printf("big num = %d",res); }


Write a program that will find the smallest largest and average values in a collection of N numbers Get the value of N before scanning each value in the collection of N numbers?

#include #include #include int main(int argc, char *argv[]){int n, smallest, largest, sum, temp;if(argc < 2){printf("Syntax: foo val1[val2 [val3 [...]]]\n");exit(1);}smallest = largest = sum = atoi(argv[1]);for(n = 2; n < argc; n++){temp = atoi(argv[n]);if(temp < smallest) smallest = temp;if(temp > largest) largest = temp;sum += temp;}printf("Smallest: %i\nLargest: %i\nAverage: %i\n", smallest, largest, sum / (argc - 1));return 0;}


What does descending mean in maths?

In Maths, we often talk about ascending and descending order. Ascending order is writing numbers from smallest to largest. Descending order is writing numbers from largest to smallest.


How do you write program to read a set of real numbers and find the range is given by the difference between largest and smallest number?

Use the following algorithm (written in pseudocode). Let largest be the lowest possible real number. Let smallest be the greatest possible real number. Repeat while there is input... { Read real number r from input. If r is greater than largest then let largest be r. If r is less than smallest then let smallest be r. } End repeat. Let range be largest minus smallest. Output range.


To take a neck measurement place the measuring tape?

Around your neck. If you need to know the smallest perimeter, then measure around the smallest part of your neck. If you need to know the largest perimeter, then measure around the largest part of your neck. If you need to know the average perimeter, then measure around the smallest part of your neck AND the largest part of your neck, add the numbers together, &amp; then divide that result by 2.