/* write a program that first reads the number of elements in the array (assume the max is 100) then randomly generates the array of integers between -50 and 50 prints an array and finds: 1. the number of zeros 2. number of positives and their average 3. number of negatives and their average */ #include #include #include #define SIZE 100 int main(){ int i,array[SIZE], num_elements, count_zero=0, count_pos=0, count_neg=0, sum_p=0, sum_n=0; printf("enter number of items\n"); scanf("%d",&num_elements); srand(time(NULL)); if(num_elements>0 && num_elements<=100){ printf("elements are\n"); for(i=0;i0){ count_pos++; sum_p+=array[i]; } else{ count_neg++; sum_n+=array[i]; } } printf("\n"); if(count_pos>0) printf("pos count and average %d and %f\n",count_pos,(double)(sum_p)/count_pos); else printf("no positives\n"); if(count_neg>0) printf("neg count and average %d and %f\n",count_neg,(double)(sum_n)/count_neg); else printf("no negatives\n"); printf("count zero %d\n",count_zero); } else printf("invalid input\n"); return 0; }