You want us to do your homework? Please read the topmost post in this beginners forum. There's a rule that you can't ask us to do your homework. You must first try and then if you're stuck somewhere, we'll be glad to help you.
#include <iostream>
usingnamespace std;
int main()
{
float s1, s2, s3; //3 subjects
double ave, tmrk; //average score + total marks
char choi; //holding Y or N input for 5 students
do
{
//input 3 scores
cout<<"Enter the marks of the 3 subjects please:-\n";
cin>>s1;
cin>>s2;
cin>>s3;
//calculating total marks
tmrk = (s1 + s2 + s3);
cout<<"The total marks of the student is "<<tmrk<<endl;
//calculating average marks
ave = (s1 + s2 + s3) / 3.0;
cout<<"The average marks for the student is "<<ave<<endl;
// enter input from another student
cout<<"Do you need to calculate total marks and average marks for other students? (Y/N) ";
cin>>choi;
}
while (choi == 'Y' || choi == 'y');
return 0;
}
//marks.cpp
//Program that uses nested loops to read the marks
//of 5 students in 3 subjects and calculate their total
//marks and average.
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
int main(){
constint STUDENTS=5;
constint SUBJECTS=3;
double subjects[STUDENTS][SUBJECTS]={};
double average[STUDENTS]={0};
for(int i=0;i<STUDENTS;i++){
cout<<"Student "<<i+1<<'\n';
for(int j=0;j<SUBJECTS;j++){ //input 3 scores
cout<<"Enter the mark of subject "<<j+1<<" :";
cin>>subjects[i][j];
average[i]+=subjects[i][j]; //calculating total marks
}//end inner for
cout<<"\nThe total marks of student "<<i+1<<" is: "<<average[i]<<endl;
average[i]/=SUBJECTS; //calculating average marks
cout<<"The average marks for student "<<i+1<<" is: "<<average[i]<<endl;
cout<<'\n'<<endl;
}//end outer for
return 0; //indicates success
}//end main
Eyenrique-MacBook-Pro:Help Eyenrique$ ./marks
Student 1
Enter the mark of subject 1 :1
Enter the mark of subject 2 :2
Enter the mark of subject 3 :3
The total marks of student 1 is: 6
The average marks for student 1 is: 2
Student 2
Enter the mark of subject 1 :2
Enter the mark of subject 2 :3
Enter the mark of subject 3 :4
The total marks of student 2 is: 9
The average marks for student 2 is: 3
Student 3
Enter the mark of subject 1 :3
Enter the mark of subject 2 :5
Enter the mark of subject 3 :7
The total marks of student 3 is: 15
The average marks for student 3 is: 5
Student 4
Enter the mark of subject 1 :0
Enter the mark of subject 2 :0
Enter the mark of subject 3 :0
The total marks of student 4 is: 0
The average marks for student 4 is: 0
Student 5
Enter the mark of subject 1 :1
Enter the mark of subject 2 :2
Enter the mark of subject 3 :1
The total marks of student 5 is: 4
The average marks for student 5 is: 1.33333