There is a task:
An array
Сof 8 real elements is specified. Count in it the number of positive, negative numbers and zeros.
As I understand it, here you need to define 2 variables (gender and neg. Numbers) to display them as a result. And to count result in the cycle for? In this case, you need to reset the counter.
Tell me how the cycle will look like? Here I wrote, but something does not display the result ... Tell me what is wrong?
#include <stdio.h> #include <stdlib.h> #include <math.h> void main() { int otrec = 0, poloj = 0, zero = 0; double A[8], i = 0; for (i = 0; i < 8; i++) { printf("Vvedite element %d\n", i); scanf ("%lf", &A[i]); if (A[i] < 0) otrec++; else if (A[i] > 0) poloj++; else if (A[i] = 0) zero++; } printf("otrec=%d\n poloj=%d\n zero=%d\n", otrec, poloj, zero); getch(); }