THIS FUNCTION IS OF TYPE "GIVE SOMETHING AND RETURN SOMETHING".
a>b?a:b means if a is greater than b then output is a otherwise b. Function " max_of_four " will return the value of maximum value out of four values.
#include <stdio.h>
int max_of_four(int a,int b,int c,int d)
{
int m,n,x;
m=a>b?a:b;
n=c>d?c:d;
x=m>n?m:n;
return x;
}
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;
}
No comments:
Post a Comment