Question: Write a program that counts the number of negative values, the number of positive values and the number of zeros in a floating point array.

Write a program that counts the number of negative values, the number of positive values and the number of zeros in a floating point array. Instead of performing these counts inside the main program, each count should be calculated by a USER-DEFINED FUNCTION.

Specificially, the program should:

greet the user,

prompt for and input the length of the array;

idiotproof the array length;

dynamically allocate the array;

check that the allocation was successful;

prompt for and input the values in the array

count the number of negative values by calling a USER-DEFINED FUNCTION;

count the number of positive values by calling a USER-DEFINED FUNCTION;

count the number of zeros by calling a USER-DEFINED FUNCTION;

output the numbers of negative, positive and zero values in the array;

deallocate the array.

NOTE: You MUST calculate each of the three counts in ITS OWN user-defined function; you are ABSOLUTELY FORBIDDEN to calculate more than one of them in the same user-defined function.

Please provide answer in C

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!