Advertisement
Guest User

Average

a guest
Nov 18th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.38 KB | None | 0 0
  1. #include <stdio.h>
  2. #define SIZE 10
  3.  
  4.  
  5. int main()
  6. {
  7.     int i,summ,counter,arr[SIZE]= {1,2,3,4,5,6,7,8,9,10};
  8.     summ = counter = 0;
  9.  
  10.     for(i=0;i<SIZE;i++)
  11.     {
  12.         if( !(i%2) && arr[i]>0)
  13.         {
  14.             summ+= arr[i];
  15.             counter++;
  16.  
  17.         }
  18.     }
  19.     printf("counter %d,summ %d,average %f\n",counter,summ,summ/counter);
  20.  
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement