Advertisement
RakibIvan99

Untitled

Dec 4th, 2022
429
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.96 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.     int num1, num2, num3, num4, max;
  6.  
  7.     /* Input three numbers from user */
  8.     printf("Enter first number: ");
  9.     scanf("%d", &num1);
  10.  
  11.     printf("Enter second number: ");
  12.     scanf("%d", &num2);
  13.  
  14.     printf("Enter third number: ");
  15.     scanf("%d", &num3);
  16.  
  17.     printf("Enter fourth number: ");
  18.     scanf("%d", &num4);
  19.  
  20.  
  21.     if(num1 > num2)
  22.     {
  23.         if(num1 > num3)
  24.         {
  25.             max = num1;
  26.         }
  27.         else
  28.         {
  29.             max = num3;
  30.         }
  31.     }
  32.     else if(num2>num4)
  33.     {
  34.         if(num2 > num3)
  35.         {
  36.             max = num2;
  37.         }
  38.         else
  39.         {
  40.             max = num3;
  41.         }
  42.     }
  43.     else
  44.     {
  45.         if(num3 > num4)
  46.         {
  47.             max = num3;
  48.         }
  49.         else
  50.         {
  51.             max = num4;
  52.         }
  53.     }
  54.  
  55.     /* Print maximum value */
  56.     printf("Maximum among all four numbers = %d", max);
  57.  
  58.     return 0;
  59. }
  60.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement