loop function for n students and n marks

So, I got this one question from my lecturer and it kinda confused me. Can anyone actually solve this out?

Write a C++ program to do the following :
PROBLEM
• Compute and display the average marks for a number of students where the number of marks and students are given by the user.
• Display the highest average mark and the lowest average mark.

and the example of the output is:

“Welcome into this page”
Do you want to continue this program?
Press y for yes or otherwise for no: y

Enter the number of students: 2
Enter the number of marks: 3

For student 1
Enter mark 1: 75
Enter mark 2: 89.5
Enter mark 3: 64.5
The average mark is 76.33

For student 2
Enter mark 1: 90
Enter mark 2: 80
Enter mark 3: 65
The average mark is 78.33

The highest average mark is 78.33 and the lowest average mark is 76.33

Do you want to continue this program?
Press y for yes or otherwise for no: n

Thank you for using this application!


This is what I've done so far:

#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;
int main ()
{
char letter, y, n;
double student, mark;

cout<< "Welcome to this application."<<endl;
cout<< "Do you want to continue this program?"<<endl;
cout<< "If yes, enter y. If no, enter n."<<endl;
cin>> letter;


return 0;
}

yeah, I know...I really don't know.
Last edited on
Hi,

Lets stick to inputting data first

You'll need 2d array and nested for loops

here's pseudo-code

1
2
3
4
//int student[no of student][no of marks]
//loop 1 which iterates no of student
     //loop 2 which iterates no of marks


just try and post again if you encounter any problem, we'll be happy to help

hope it helps

further reading

http://www.cplusplus.com/doc/tutorial/arrays/
http://www.cplusplus.com/doc/tutorial/control/

dear shadder,

#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;
int main ()
{
int student [5][3]
int n=1<5;

while (n>0)
{

}
}

so far, is it right?
dear naaaaaaa,

int n=1<5;
that's a syntax error

1
2
3
4
5
for(int i=0;i<5;i++)
     {
     for (int j=0;j<3;j++)
          //input statements here
     }


this is one of the possibilities for inputting the 2D array

keep going :)
Topic archived. No new replies allowed.