Write a program that reads from the user, the grades of 10 students in the final
ID: 3840387 • Letter: W
Question
Write a program that reads from the user, the grades of 10 students in the final of 3 questions.
It stores the grades in a 2D array. Then it finds the following:
1. Display the 2D array of all grades along with the total of each student
2. The questions where the students have the worst and best totals.
A sample output of the program is shown below:
Write a program that reads form the user the grades of 10 students in an exam of 3 questions. lt stores the grades in a 2D array. Then it finds the following: 1. Display the 2D array of all grades along with the total of each student 2. The questions where the students have the worst and best totals. A sample output of the program is shown below: The class list ID Q1 Q2 Q3 Total 6.0 5.0 8.0 19.0 2.0 4.0 2.0 8.0 3 6.0 5.0 7.0 18.0 3.0 8.0 1.0 12.0 7.0 8.0 10.0 25.0 6 5.0 6.0 3.0 14.0 9.0 6.0 10.0 25.0 8 10.0 4.0 9.0 23.0 7.0 6.0 5.0 18.0 10 8.0 7.0 7.0 22.0 Question 2 has best total uestion 1 has wort totalExplanation / Answer
#include<iostream.h>
#include<iomanip.h>
#include<conio.h>
float total_marks(float []);
main()
{
clrscr();
float marks[10][3]={0};
cout<<" Enter the marks of the ten students : "<<endl;
for(int count_1=0;count_1<10;count_1++)
{
cout<<" Enter the marks obtained by student "<<count_1+1<<
" :"<<endl;
cout<<" Question-1 = ";
cin>>marks[count_1][0];
cout<<" Question-2 = ";
cin>>marks[count_1][1];
cout<<" Question-3 = ";
cin>>marks[count_1][2];
}
getch();
clrscr();
cout<<" ********************************* Result Sheet *****************************"<<endl;
cout<<" Student No. Question-1 Question-2 Question-3 ";
cout<<"Total Marks "<<endl;
for(int count_2=0;count_2<10;count_2++)
{
cout<<setw(8)<<count_2+1;
cout<<setw(13)<<marks[count_2][0];
cout<<setw(11)<<marks[count_2][1];
cout<<setw(11)<<marks[count_2][2];
cout<<setw(11)<<total_marks(marks[count_2]);
cout<<endl;
}
cout<<" ******************************************************************************";
getch();
return 0;
}
/*************************************************************************///----------------------- total_marks(float []) -----------------------///*************************************************************************/float total_marks(float marks[])
{
float sum=0;
for(int count=0;count<3;count++)
sum+=marks[count];
return sum;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.