Read the question, write C on the right, then Run or Check.
QuestionHint and solution stay closed until you open them
Read three integers and print the largest one.
If two or more values tie for largest, print that value once.
Input. Three integers a, b, and c.
Output. One integer — the maximum.
Constraints
- -1000 ≤ a, b, c ≤ 1000
Examples
Input
3 9 4
Output
9
Input
5 5 2
Output
5
Hint
- Start with max = a, then compare b and c.
- You can also nest if statements, or write if (a >= b && a >= c).
Show correct code
Peek only after you have tried. You can still Check your own version.
#include <stdio.h>
int main(void) {
int a, b, c;
if (scanf("%d %d %d", &a, &b, &c) == 3) {
int max = a;
if (b > max) max = b;
if (c > max) max = c;
printf("%d\n", max);
}
return 0;
}
main.cC17 · gcc · Ctrl + Enter runs
ResultIdle
Run to see output. Check grades the tests.