Advertisement
pranto_95

input 5 numbers and calculate the average & how many of thos

Jun 17th, 2015
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.42 KB | None | 0 0
  1. /*input 5 numbers and calculate the average & how many of those are above average*/
  2.  
  3. #include<stdio.h>
  4. int main(){
  5.     int i,n,c,s=0,x[5];
  6.     float avg;
  7.     for(i=0;i<5;i++){
  8.             scanf("%d",&x[i]);
  9.             s=s+x[i];
  10.     }
  11.     avg=s/5.0;
  12.     printf("avg is %0.3f\n",avg);
  13.     c=0;
  14.     for(i=0;i<5;i++){
  15.             if(x[i]>avg){
  16.             c++;
  17.             }
  18.     }
  19.     printf("%d",c);
  20.     return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement