Advertisement
PROFESSOR_AIH

positives and average

Mar 28th, 2022
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.34 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4.     int i,count=0;
  5.     float num,sum=0;
  6.     for(i=1; i<=6; i++)
  7.     {
  8.         scanf("%f",&num);
  9.         if(num>0)
  10.         {
  11.             count++;
  12.             sum=sum+num;
  13.         }
  14.         num=0;
  15.     }
  16.     printf("%d valores positivos\n",count);
  17.     printf("%.1f\n",(sum/count));
  18.     return 0;
  19. }
  20.  
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement