COMP 235, Fall 2021, Program 2

Dynamic Memory

Due Friday, September 10 by the start of class.

You will need to do this assignment on the department server (cs.monm.edu). Start early!

Start by creating a single C source file. You are going to write a program that lets the user input some integers, then outputs some statistics about them.

Your program needs to:

  1. Prompt the user for a number (the number of integers to input).
  2. Let the user input one integer at a time, until the desired number of integers are received.
  3. Print out all the integers on one line, separated by a comma (no spaces).
  4. Compute and print out the min, max, average, and sum.

You may assume that the user always enters integers correctly (e.g., no floats or weird inputs). You should use dynamic memory to store the input numbers.

It might look something like this:

$ gcc -o nums nums.c
$ ./nums
How many integers? 5
> 1
> 3
> 42
> 7
> -1
You entered: 1,3,42,7,-1
Min: -1
Max: 42
Avg: 10.40
Sum: 52

Submission

We will submit using the handin program using assignment “proj2”. For example:

handin comp235 proj2 nums.c