Largest of Three
Completed
Read three integers and print the largest.
Input
Three integers.
Output
The largest.
Example
Input
3 9 4
Output
9
Editor
C
Hints
Assume the first is largest, then compare the others.
Solution explanation
A single statement after if doesn't need braces, but braces avoid mistakes.
Show solution
#include <stdio.h>
int main() {
int a, b, c;
scanf("%d %d %d", &a, &b, &c);
int max = a;
if (b > max) max = b;
if (c > max) max = c;
printf("%d\n", max);
return 0;
}