Computer Science C++

profilemusafa5
l10.201_two_dim_arrays.docx

CMPSC 201 S15

Lab #10: 2-Dimensional Arrays

This is due at the end of lab today.

Objective: Write a program manipulating a 2-dimensional array.

Reference: Chapter 8 and lectures

· The data file on Angel holds grades for a class of 20 students. Each row represents a student and each column represents an assignment.

· Create constants to represent your number of students and number of assignments.

· Your program should read the data into a 2-dimensional array. Then modify a previous function to calculate the average grade for each assignment. The function prototype will be:

double Average (int g[NSTDS][NASG], int a);

Where a represents which assignment you want to calculate the average for.

· Your output will echo the 2-dimensional array with the columns and rows clearly marked and the average for each column at the end of each column.

· HINT: When you calculate the averages, you manipulate both the row and columns with for loops. Because your function is only calculating the average of for ONE assignment, one loop will be in the average function and one will be in the main function.

· HINT: Read in your data, echo to screen to confirm correct. Then write your function and use it.

When you have successfully completed the entire lab:

1. Notify the instructor or lab assistant.

2. Demonstrate that your code executes correctly without any errors.

3. Turn in the hard copy of your original source code and a copy of the output screen.

4. Upload your final source code to the drop box on Angel.

Graded on:

·

2

· Good programming style

· Comments

· Neat & Readable

· Logic

· Input

· Output

· Function

· Function Header

· Data Files

· Array manipulations