daily pastebin goal
11%
SHARE
TWEET

Untitled

a guest Feb 13th, 2018 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<stdio.h>
  2.  
  3. void main()
  4. {
  5.     int num[5];
  6.     int i,j;
  7.     float avg;
  8.     int sum,max,min;
  9.     int temp;
  10.  
  11.     for(i=0;i<5;i++)
  12.     {
  13.         scanf("%d",&num[i]);
  14.     }
  15.     //sort
  16.     for(i=0;i<5;i++)
  17.     {
  18.         for(j=0;j<5;j++)
  19.         {
  20.             if(num[j]>num[j+1])
  21.             {
  22.                 temp = num[j];
  23.                 num[j] = num[j+1];
  24.                 num[j+1] = temp;
  25.             }
  26.         }
  27.     }
  28.     /*
  29.     for(i=0;i<5;i++)
  30.     {
  31.         printf("%d ",num[i]);
  32.     }*/
  33.  
  34.     avg = (num[0]+num[1]+num[2]+num[3]+num[4])/5.0;
  35.     sum = num[0]+num[1]+num[2]+num[3]+num[4];
  36.     min = num[0];
  37.     max = num[5];
  38.  
  39.     printf("AVG = %.1f\n",avg);
  40.     printf("SUM = %d\n",sum);
  41.     printf("MIN = %d\n",min);
  42.     printf("MAX = %d",max);
  43. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top