


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Instructions for a programming assignment that involves using two-dimensional arrays in c. The assignment includes downloading a source file and data file, writing functions to find the player with the most hits and calculate batting averages, and displaying all statistics for all players. Students are expected to become familiar with using two-dimensional arrays to solve problems and learn how to correctly pass a two-dimensional array to a function.
Typology: Assignments
1 / 4
This page cannot be seen from the preview
Don't miss anything!



Name: Sec: 06/22/
Two dimensional arrays can be thought of as tables of data. A familiar example of a table of data is the spreadsheet, such as Microsoft Excel, where you arrange data into rows and columns. To declare a 2D imensional array in C, we do the following: const int NUM_ROWS = 8; const int NUM_COLUMNS = 5; int table[NUM_ROWS][NUM_COLUMNS]; The above, as you can probably guess, creates an array called table, that can hold/represent a table with 8 rows and 5 columns. Of course, by changing the named constants NUM_ROWS and/or NUM_COLUMNS, you can change the size of the table that is being created and represented. However, unlike a spreadsheet, 2di mensional arrays in C must always start at index 0 for both the row index and the column index. By convention, the first index is used to index the row number, and the second index the column number. This convention is somewhat arbitrary, they could be reversed, but in most of mathematics and programming you will see people using this ordering when working with 2 dimensional tables, so it is a good idea to just memorize this ordering. So, a visual representation of the 2di mensional table variable, declared above, would be: table [0] [1] [2] [3] [4] [0] [1] [2] [3] [4] 25 [5] [6] [7]
To assign a value into a 2di mensional table, we do the same as for a 1 dimensional array, except we specify 2 indexes, the row, column. So, to assign the value 25 to the cell shown in the table, which is in the row with index 4 and the column with index 1, we would do: table[4][1] = 25; In this program, you will use and manipulate data in a 2di mensional array.
Become familiar with using 2di mensional array to solve problems. Also, learn how to correctly pass a 2di mensional array to a function.
You have now completed Program 3. As with previous assignments, the final step you should perform when you complete an assignment is to upload your finished assignment to your eCollege account. Go ahead at this point and upload your PlayBall.cpp source file to eCollege. Once this is done you have successfully completed the programming assignment #3.