In this Hackerrank Functions in C problem we need to develop a C Program in which we need to write a function max_of_four with four integer parameters and integer return type and then it should return the greatest value among them.


HackerRank Functions in C problem solution

HackerRank Functions in C problem solution

#include <stdio.h>
/*
Add `int max_of_four(int a, int b, int c, int d)` here.
*/

int max_of_four(int a, int b, int c, int d) {
    return ((a>b?a:b)>(c>d?c:d)?(a>b?a:b):(c>d?c:d));
}

int main() {
    int a, b, c, d;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    int ans = max_of_four(a, b, c, d);
    printf("%d", ans);
    
    return 0;
}