Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main(int argc, char *argv[]) {
- int i=0,j=0;
- float x;
- float avg=0;
- do
- {
- printf("Input a number: ");
- scanf("%f",&x);
- if(x>0)
- {
- avg+=x;
- i++;
- }
- if(abs(x)<100)
- {
- if(x==0) break;
- j++;
- }
- } while (x!=0);
- if(i!=0)
- {
- avg=avg/i;
- printf("The average of positive numbers equals: %.2f",avg);
- } else printf("The number of positive numbers is 0. Cannot calculate average!");
- printf("\nThe quantity of numbers which absolute value is lower than 100 is: %d",j);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement