Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Positive and negative. (from Chapter 11) Write a function, named sums(), that has two input parameters; an array, called Input of doubles; and an integer

Positive and negative. (from Chapter 11)

Write a function, named sums(), that has two input parameters; an array, called Input of doubles; and an integer which is the number of values stored in the array. Compute the sum of the positive values in the array and the sum of the negative values. Also count the number of values in each category. Return these four answers through output parameters. Write a main program that reads no more than 10 real numbers and stores them in an array. Stop reading numbers when a 0 is entered. Call the sums() function and print the answers it returns. Also compute and print the average values of the positive and negative sets. Align decimal points on numbers

SAMPLE INPUT: -123.45 -234.56 576.1 -9.345 675.2 100 -10 1654.45 765.89 0 (NOT in computation)

SAMPLE OUTPUT:

YourName Program#8 CSCI1110

Input Read: 9999.9999 9999.9999 ...

Statistics: Desc Number Total: Average: Positive 99 99999.9999 9999.9999 Negative 99 99999.9999 9999.9999 Overall 99 99999.9999 9999.9999

----PARTIAL SAMPLE OUTPUT: Negative 4 -377.3550 -94.3388

Your function call will look something like sums(input[], n, &sumPos, &sumNeg, &countPos, &countNeg)

RUBRIC/CHECKLIST

Output Correct including echo the input with implied decimal point aligned

Indentation

Comments

Used defines for all constants

Read into the array until a 0 is entered, only one set of data is used

Output numbers should aligned

Functions with prototypes sums must be included. More functions can be used but NOT less.

Pointers MUST be used

Output copied into Input

Filename

Upload to Bb9

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions