Generation

generate functionFri, 20 Jan 2023

Дана последовательность из М чисел. Подсчитать, сколько в ней отрицательных, и сколько положительных и сколько нулевых элементов. Найти произведение отрицательных. using while

#include <stdio.h> #include <stdlib.h> #include <math.h> int main() { int i, m, a[10], p=0, n=0, z=0; float mul=1; printf("Enter array length: "); scanf("%d", &m); for (i=0; i<m; i++) { printf("a[%d]=", i); scanf("%d", &a[i]); } for (i=0; i<m; i++) { if (a[i]>0) { p++; } else if (a[i]<0) { n++; mul*=a[i]; } else { z++; } } printf("Positive: %d\nNegative: %d\nZero: %d\nProduct: %f",

Questions about programming?Chat with your personal AI assistant