Hi Guys,

Have a program which works, and uses a two-dimensional array to calculate and output marks for a course - and also calculate the average.

Now got it to work, but the columns are all-over the place when it runs. Tried messing around with setw, but I just can't get it right! Can someone please help!

Numbers.cpp
Code:
//Numbers.cpp
// A program that uses a 5 by 6 array of numbers
#include "numbers.H"
#include <cstdlib>
int main ()
{
  course numbers;
  numbers.get_marks();
  numbers.display_marks();
  system ("pause");
  
}
Numbers.h

Code:
 
// Numbers.h
// The Object Class Numbers

# include <iostream>
using namespace std;
# include <iomanip>
using namespace std;
  const int no_of_modules=4;
  const int no_of_students=6;
  
class course
  {
  public:
    int get_marks();
    int display_marks();
  protected:
    int marks [no_of_modules][no_of_students];
  };

int course::get_marks()
{
  char terminator;
  for (int module_index=0; module_index <
  no_of_modules; ++ module_index)
    {
    for (int student_index=0; student_index < no_of_students; ++ student_index)
      {
      cout <<"Enter a mark for module no: "
      << module_index << " student no: "
      << student_index << " : ";
      cin >> marks [module_index]
      [student_index];
      }
    }
    cin.get(terminator);
}

int course::display_marks()
{
  int module_total;
  cout <<
    "     0     1     2     3     4     5"
    << "     Average"  <<endl;
  for (int module_index=0; module_index <
  no_of_modules; ++ module_index)
  {
  module_total=0;
  cout <<"Module No: " <<module_index
       << "       "; 
  for (int student_index=0; student_index < no_of_students; ++ student_index)
       {
       cout << setw (6) <<marks[module_index][student_index];
       module_total += marks [module_index][student_index];     
       cout << setw (7) << module_total / no_of_students << endl;
       }
   }
}
Thanks