Advertisement
Dido09

C - Function

Aug 7th, 2022
589
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.49 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int max(int num1, int num2, int num3){
  5.     int result;
  6.  
  7.     if(num1 > num2 && num1 > num3){
  8.         result = num1;
  9.     }else if(num2 > num1 && num1 > num3){
  10.         result = num2;
  11.     }else if(num3 > num1 && num2){
  12.         result = num3;
  13.     }
  14.     return result;
  15. }
  16.  
  17. int main(){
  18.  
  19. int num1, num2, num3;
  20.  
  21. printf("Enter three numbers to compare: ");
  22. scanf("%d%d%d", &num1, &num2, &num3);
  23.  
  24. printf("%d", max(num1, num2, num3));
  25.  
  26.     return 0;
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement