Advertisement
noor017

Positives and Average

Jun 13th, 2015
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.36 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.     double n, s, media;
  6.     int i, total = 0;
  7.  
  8.     for (i=1; i<=6; i++)
  9.     {
  10.         scanf("%lf", &n);
  11.  
  12.         if (n > 0)
  13.         {
  14.             total++;
  15.             s=s+n;
  16.             media=s/total;
  17.         }
  18.     }
  19.  
  20.      printf("%d valores positivos\n", total);
  21.      printf("%.1lf\n", media);
  22.  
  23.      return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement