int-calcs.c (825B)
1 #include <stdio.h> 2 3 int main(int argc, char *argv[]) 4 { 5 int num, averPos, sqrOdd; 6 int sumPos = 0, numPos = 0, numEven = 0, prodNeg = 1; 7 8 do 9 { 10 printf("Number: "); 11 scanf("%d", &num); 12 13 if (num > 0) 14 { 15 sumPos += num; 16 numPos += 1; 17 18 19 if (num % 2 != 0) 20 { 21 sqrOdd = num * num; 22 printf("Square of odd number %d: %d\n", num, sqrOdd); 23 } 24 else 25 numEven += 1; 26 } 27 else if (num < 0) 28 prodNeg *= num; 29 } 30 while (num != 0); 31 32 averPos = sumPos / numPos; 33 34 printf("Average value of positive numbers: %d\n", averPos); 35 printf("Product of negative numbers: %d\n", prodNeg); 36 printf("Number of even numbers: %d\n", numEven); 37 38 return 0; 39 }