We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
int greatest_of_four(int a, int b, int c, int d) {
int max = a;
if (b > max) {
max = b;
}
if (c > max) {
max = c;
}
if (d > max) {
max = d;
}
return max;
}
int main() {
int num1, num2, num3, num4;
// Input
scanf("%d", &num1);
scanf("%d", &num2);
scanf("%d", &num3);
scanf("%d", &num4);
// Output the greatest of the four integers
printf("%d\n", greatest_of_four(num1, num2, num3, num4));
return 0;
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Functions
You are viewing a single comment's thread. Return to all comments →
include
int greatest_of_four(int a, int b, int c, int d) { int max = a; if (b > max) { max = b; } if (c > max) { max = c; } if (d > max) { max = d; } return max; }
int main() { int num1, num2, num3, num4;
}