Westonci.ca is the Q&A platform that connects you with experts who provide accurate and detailed answers. Explore a wealth of knowledge from professionals across different disciplines on our comprehensive platform. Experience the ease of finding precise answers to your questions from a knowledgeable community of experts.
Sagot :
The program illustrates the use of arrays and loops.
Arrays
Arrays are data types that hold multiple values in a variable, while loops are used to perform repetitive operations
The C++ program
The program in C++, where comments are used to explain each line is as followed:
#include <iostream>
using namespace std;
int main(){
//This declares a 2D array of 10 rows and 5 columns
int scores [10][5];
//The following iteration gets input into the 2D array
for(int i = 0; i < 10;i++){
for(int j = 0; j <5; j++){
cin>>scores[i][j];
}
}
//This declares an array for the average score by each student
int average [10];
//This initializes a counter k to 0
int k = 0;
//This iterates through the scores of each student
for(int i = 0; i < 10;i++){
//This prints an output header
cout<<"Student "<<i+1<<": ";
//This initializes the student score to 0
int score =0;
for(int j = 0; j <5; j++){
//This prints the current score of the student
cout<<scores[i][j]<<" ";
//This calculates the total score
score+=scores[i][j];
}
//This calculates the average score
average[k] = score/10;
k++;
//This prints a new line
cout<<'\n';
}
//This declares an array for the average score in each subject
int marks [5];
//This initializes a counter k to 0
k = 0;
//This iterates through the scores of each subject
for(int i = 0; i < 5;i++){
int score =0;
for(int j = 0; j <10; j++){
//This calculates the total score
score+=scores[j][i];
}
//This calculates the average score
marks[k] = score/10;
k++;
}
return 0;
}
Read more about similar programs at:
https://brainly.com/question/14286128
Visit us again for up-to-date and reliable answers. We're always ready to assist you with your informational needs. Thanks for stopping by. We strive to provide the best answers for all your questions. See you again soon. Find reliable answers at Westonci.ca. Visit us again for the latest updates and expert advice.