Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main()
- {
- int n = 0; //Our input var
- int count = 0; //Used to count how much numbers we have
- int sum = 0; //The total sum of positive numbers
- int result = 0; //The arithmetic mean
- //Get first input
- printf("Vuvedete n: ");
- scanf("%d", &n);
- //We need continuous input for numbers in range [-100; 100]
- while(n >= -100 && n <= 100)
- {
- //Check if number is positive
- if(n > 0)
- {
- count++; //Increase count
- sum += n; //Add to the total sum
- result = sum / count; //Get arithmetic mean
- printf(" Sredno aritmetichno: %d\n", result);
- printf(" Vuvedete sledvashto n: ");
- scanf("%d", &n);
- }
- }
- printf("Sredno aritmetichno: %d\n", result);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement