HackerRank C- Functions in C




You have to write a function int max_of_four(int a, int b, int c, int d) which reads four arguments and returns the greatest of them



  1. #include <stdio.h>
  2. int max_of_four(int a, int b, int c, int d)
  3. {
  4. int max=0;
  5. if(max<a)
  6. max=a;
  7. if(max<b)
  8. max=b;
  9. if(max<c)
  10. max=c;
  11. if(max<d)
  12. max=d;
  13. return max;
  14. }
  15. int main() {
  16. int a, b, c, d;
  17. scanf("%d %d %d %d", &a, &b, &c, &d);
  18. int ans = max_of_four(a, b, c, d);
  19. printf("%d", ans);
  20. return 0;
  21. }




codesadda.com

Codesadda.com is your home of programming solutions, tutorials, video tutorials and much more. Sign Up for our weekly newsletter to get update about new content.

Like us on Facebook | Connect with us on LinkedIn | Subscribe our Channel on Youtube