



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
Two lab exercises from a computer science course. The first exercise introduces parallel arrays and processing them. The second exercise focuses on manipulating data in a two-dimensional array, including initializing, printing, inputting, summing, and finding the largest element in a column. Students are required to write designs and programs based on the given objectives.
Typology: Lab Reports
1 / 6
This page cannot be seen from the preview
Don't miss anything!




Parallel arrays are two or more arrays whose corresponding components hold related information. If you need to keep track of multiple items that are related, you can create more than one array where the information is related by the placement within the arrays.
In this lab, you process parallel arrays. After completing this lab, you will be able to: Process parallel arrays.
In the following exercises, select the correct answer for each question. Then design and write a program that uses parallel arrays.
(Circle the correct answer)
int stats[2][3] = {4, 4, 4, 3, 12, 15}; int totalHits = 0; for (int row=0; row<2; row++) totalHits += stats[row][0];
int stats[2][3] = {4, 4, 4, 3, 12, 15}; int atBats[2] = {0}; for (int row=0; row<2; row++) { for (int column = 0; column < 3; column++) atBats[row] += stats[row][column]; cout << “Player “ << row + 1 << “was up to bat “ << atBats[row] << “times.” << endl; }