Welcome to Westonci.ca, your ultimate destination for finding answers to a wide range of questions from experts. Explore thousands of questions and answers from a knowledgeable community of experts on our user-friendly platform. Our platform provides a seamless experience for finding reliable answers from a network of experienced professionals.
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
We hope our answers were helpful. Return anytime for more information and answers to any other questions you may have. Thank you for your visit. We're dedicated to helping you find the information you need, whenever you need it. We're dedicated to helping you find the answers you need at Westonci.ca. Don't hesitate to return for more.