Scan Array

This is a warmup exercise. It is not compulsory, and may be completed individually or with your lab partner.

You should make sure you have completed showArray before completing this task.

Download scanArray.c, or copy it into your current directory on a CSE system by running

$ cp /web/cs1511/17s2/week05/files/scanArray.c .

Copy your showArray function code into scanArray.c.

Next, write the void scanArray(int size, int array[MAX_LENGTH]) function, which is given an array and its size and scans in values from standard input to fill the array.

Some Examples

Enter array size: 3
Enter array values: 1 2 3
[1, 2, 3]
Enter array size: 1
Enter array values: 17
[17]

To run some simple automated tests:

$ 1511 autotest scanArray

To run Styl-o-matic:

$ 1511 stylomatic scanArray.c
Looks good!

You’ll get advice if you need to make changes to your code.

Submit your work with the give command, like so:

$ give cs1511 wk05_scanArray

Or, if you are working from home, upload the relevant file(s) to the wk05_scanArray activity on Give Online.