Welcome to Westonci.ca, the place where your questions find answers from a community of knowledgeable experts. Experience the ease of finding accurate answers to your questions from a knowledgeable community of professionals. Discover in-depth answers to your questions from a wide network of professionals on our user-friendly Q&A platform.
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
Thank you for choosing our platform. We're dedicated to providing the best answers for all your questions. Visit us again. Thanks for using our service. We're always here to provide accurate and up-to-date answers to all your queries. Thank you for trusting Westonci.ca. Don't forget to revisit us for more accurate and insightful answers.