For example, if the input were
5 3.7 5.2 -4.7 -62 14.7
the output might be
Sum: -43.1
Average: -8.62
3 of your 5 numbers are positive.
Also turn in sample runs with well-chosen test cases.
Note: in C or C++, you can demonstrate the use of pointers and memory management by using a pointer rather than an array declaration, and allocating exactly as much memory as necessary. In Java, this is the only natural way to do it.
Write three functions sum,
average, and count-positive, each of which
takes in a list of numbers and returns a number.
If you want
to practice your Scheme I/O, you can then write a 0-parameter function
named hw2 that asks the user for a number, prints an error
message if it's less than 0, more than 100, or not an integer,
and otherwise asks for that many numbers, forms them into a list, and
prints the results as above.
If you want to learn about Scheme vectors, try doing the same thing using a vector rather than a list.
As in the Scheme version, using Prolog lists.