Language: C Programming // produce result: Median of {1, 5, 9}: 5 Median of {9,
ID: 3744914 • Letter: L
Question
Language: C Programming
// produce result:
Median of {1, 5, 9}:
5
Median of {9, 5, 1}:
5
Median of {1, 9, 5}:
5
Median of {9, 1, 5}:
5
Median of {5, 1, 9}:
5
Median of {5, 9, 1}:
5
Median of {1, 1, 5}:
1
Median of {1, 5, 1}:
1
Median of {5, 1, 1}:
1
Median of {1, 1, 1}:
1
Hooray! (This will print even if you're not getting the correct results.)
void print_median_of_three(int a, int b, int c);
int main(void)
{
// expected result: 5
printf("Median of {1, 5, 9}: ");
print_median_of_three(1, 5, 9);
printf(" ");
// expected result: 5
printf("Median of {9, 5, 1}: ");
print_median_of_three(9, 5, 1);
printf(" ");
// expected result: 5
printf("Median of {1, 9, 5}: ");
print_median_of_three(1, 9, 5);
printf(" ");
// expected result: 5
printf("Median of {9, 1, 5}: ");
print_median_of_three(9, 1, 5);
printf(" ");
// expected result: 5
printf("Median of {5, 1, 9}: ");
print_median_of_three(5, 1, 9);
printf(" ");
// expected result: 5
printf("Median of {5, 9, 1}: ");
print_median_of_three(5, 9, 1);
printf(" ");
// expected result: 1
printf("Median of {1, 1, 5}: ");
print_median_of_three(1, 1, 5);
printf(" ");
// expected result: 1
printf("Median of {1, 5, 1}: ");
print_median_of_three(1, 5, 1);
printf(" ");
// expected result: 1
printf("Median of {5, 1, 1}: ");
print_median_of_three(5, 1, 1);
printf(" ");
// expected result: 1
printf("Median of {1, 1, 1}: ");
print_median_of_three(1, 1, 1);
printf(" ");
printf("Hooray! (This will print even if you're not getting the correct results.) ");
return 0;
}
Explanation / Answer
#include void print_median_of_three(int a, int b, int c) { int min = a, max = a; if(b > max) { max = b; } if(c > max) { max = c; } if(bRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.