CISC 1110  Lab 15


        Write a main program that declares two integer arrays, nums and vals, each large enough to hold 10 values. Declare an integer variable n to hold the number of values read into each array.  Main will read in data and call two functions.

In the main program, read in data from a file into the two arrays. First read in n (make it 5 or 6) and then—in a single loop--read n values into each of the two arrays. (This is just an extension of what you did in the last lab, filling two arrays instead of just one.)

Sample file input (in this example, n is 3)


10  12

6   3

7   7

The data values in the left column should go into array nums, and the data values in the right column should go into array vals.

           Next, call a function printarray and send it three parameters: the integer n and two arrays, nums and vals. The printarray function should print n and then print the values in the two arrays in columns, with spaces between, like this:

There are 3 values in the arrays

10  12

 6   3

7    7

           Last, call a function addup that receives two parameters: the integer n  and the vals array. In the function, sum the n values in the vals array and return the sum to main. Have main print the returned value.