The following program accepts five student names and 4 test scores for each. Then calculates and displays the average and letter grade for each students. Well, that is what it is supposed to do. Judging by the long list of errors I get, it looks like none of my arguments are being successfully passed. Any help would be greatly appreciated!

#include <iostream>
#include <iomanip>
using namespace std;

char getStuNames(char*[21], int);
double getStuGrades(char*[21], double**, int, int);
void displayGrade(char*[21], double**, int, int);


int main() {

    const int stu = 5;
    const int num = 4;
    char stuNames[stu][21];
    double stuGrades[stu][num];

    getStuNames(stuNames, stu);
    getStuGrades(stuNames, stuGrades, stu, num);

    displayGrade(stuNames, stuGrades, stu, num);

    cout << "\n\n\n\n";

    return 0;
}
/**************************************************/
char getStuNames(char*[21] stuNames, int stu) {

    for (int i = 0; i <= stu; i++) {
        cout << "\n\n\t\tGrade Book"
             <<   "\n\t\t_____________________________________________"
             << "\n\n\t\tEnter name of student " << ( i + 1 ) << ": ";
        cin.get(stuNames[i][21]);
        cin.ignore();
    }

    return stuNames[stu][21];
}
/**************************************************/
double getStuGrades(char*[21] stuNames, double** stuGrades, int stu, int num) {

    for (int i = 0; i < stu; i++) {
        cout << "\n\n\t\tGrade Book"
             <<   "\n\t\t_____________________________________________"
             << "\n\n\t\tGrades for student: " << setw(25) << stuNames[i][21] << " ";
        for (int j = 0; j < num; j++) {
            do {
                cout << "\n\n\t\tEnter score " << ( j + 1 ) << ": ";
                cin  >> stuGrades[j];
            }while (stuGrades[j] < 0 || stuGrades[j] > 100);
        }
    }
    return stuGrades[stu][num];
}
/**************************************************/
double getAvg(double stuGrades**, int i, int num) {

    // Calculate Total For Each Student
    double total = 0;
    for (int j = 0; j < num; j++) total += stuGrade[i][j];

    // Calculate Average
    double average = (total / num);

    return average;
}
/**************************************************/
char getLet(double average) {

    // Determine Letter Grade
    char letter;
    if (average > 89) letter = 'A';
    else if (average > 79) letter = 'B';
    else if (average > 69) letter= 'C';
    else if (average > 59) letter = 'D';
    else letter = 'F';

    return letter;
}
/**************************************************/
void displayGrade(char*[21] stuNames, double** stuGrade, int stu, int num) {

    int i;
    cout << "\n\n\t\tGrade Book"
         <<   "\n\t\t_____________________________________________"
         << "\n\n\t\tStudent              Average(%)  Letter Grade";
    cout << setprecision(1) << showpoint << fixed;
    for (i = 0; i < stu; i++) {
        double average = getAvg(stuGrade, i, num);
        char letter = getLet(average);
        cout << "\n\t\t"
             << setw(21) << stuNames[i][21]
             << setw(5)  << average
             << setw(14) << letter;
    }

}

Which lines is it complaining about?

Also, in general, you cannot/should not do this:

char stuNames[stu][21];
    double stuGrades[stu][num];

The numbers in [ ] need be determined at compile time, or you need to dynamically allocate the array using "new".

Your declarations should be more like this. Change the definitions to match.

char getStuNames(char [][21], int);
double getStuGrades(char [][21], double [][4], int, int);
void displayGrade(char [][21], double [][4], int, int);

Your declarations should be more like this. Change the definitions to match.

char getStuNames(char [][21], int);
double getStuGrades(char [][21], double [][4], int, int);
void displayGrade(char [][21], double [][4], int, int);

Okay, now my code looks like:

#include <iostream>
#include <iomanip>
using namespace std;

char getStuNames(char[][21], int);
double getStuGrades(char[][21], double[][4], int, int);
void displayGrade(char[][21], double[], int, int);


int main() {

    const int stu = 5;
    const int num = 4;
    char stuNames[stu][21];
    double stuGrades[stu][4];

    getStuNames(stuNames, stu);
    getStuGrades(stuNames, stuGrades, stu, num);

    displayGrade(stuNames, stuGrades, stu, num);

    cout << "\n\n\n\n";

    return 0;
}
/**************************************************/
char getStuNames(char[][21] stuNames, int stu) {

    for (int i = 0; i <= stu; i++) {
        cout << "\n\n\t\tGrade Book"
             <<   "\n\t\t_____________________________________________"
             << "\n\n\t\tEnter name of student " << ( i + 1 ) << ": ";

        cin.get(stuNames[i][21]);
        cin.ignore();
    }

    return stuNames[stu][21];
}
/**************************************************/
double getStuGrades(char[][21] stuNames, double[][4] stuGrades, int stu, int num) {

    for (int i = 0; i < stu; i++) {
        cout << "\n\n\t\tGrade Book"
             <<   "\n\t\t_____________________________________________"
             << "\n\n\t\tGrades for student: " << setw(25) << stuNames[i][21] << " ";
        for (int j = 0; j < num; j++) {
            do {
                cout << "\n\n\t\tEnter score " << ( j + 1 ) << ": ";
                cin  >> stuGrades[j];
            }while (stuGrades[j] < 0 || stuGrades[j] > 100);
        }
    }
    return stuGrades[stu][4];
}
/**************************************************/
double getAvg(double stuGrades[][4], int i, int num) {

    // Calculate Total For Each Student
    double total = 0;
    for (int j = 0; j < num; j++) total += stuGrade[i][j];

    // Calculate Average
    double average = (total / num);

    return average;
}
/**************************************************/
char getLet(double average) {

    // Determine Letter Grade
    char letter;
    if (average > 89) letter = 'A';
    else if (average > 79) letter = 'B';
    else if (average > 69) letter= 'C';
    else if (average > 59) letter = 'D';
    else letter = 'F';

    return letter;
}
/**************************************************/
void displayGrade(char[][21] stuNames, double[][4] stuGrade, int stu, int num) {

    int i;
    cout << "\n\n\t\tGrade Book"
         <<   "\n\t\t_____________________________________________"
         << "\n\n\t\tStudent              Average(%)  Letter Grade";
    cout << setprecision(1) << showpoint << fixed;
    for (i = 0; i < stu; i++) {
        double average = getAvg(stuGrade, i, num);
        char letter = getLet(average);
        cout << "\n\t\t"
             << setw(21) << stuNames[i][21]
             << setw(5)  << average
             << setw(14) << letter;
    }

}

and my errors are:

hw09_13.cpp: In function âint main()â:
hw09_13.cpp:20: error: cannot convert âdouble (*)[4]â to âdouble*â for argument â2â to âvoid displayGrade(char (*)[21], double*, int, int)â
hw09_13.cpp: At global scope:
hw09_13.cpp:27: error: expected â,â or â...â before âstuNamesâ
hw09_13.cpp: In function âchar getStuNames(char (*)[21])â:
hw09_13.cpp:29: error: âstuâ was not declared in this scope
hw09_13.cpp:34: error: âstuNamesâ was not declared in this scope
hw09_13.cpp:38: error: âstuNamesâ was not declared in this scope
hw09_13.cpp:38: error: âstuâ was not declared in this scope
hw09_13.cpp: At global scope:
hw09_13.cpp:41: error: expected â,â or â...â before âstuNamesâ
hw09_13.cpp: In function âdouble getStuGrades(char (*)[21])â:
hw09_13.cpp:43: error: âstuâ was not declared in this scope
hw09_13.cpp:46: error: âstuNamesâ was not declared in this scope
hw09_13.cpp:47: error: ânumâ was not declared in this scope
hw09_13.cpp:50: error: âstuGradesâ was not declared in this scope
hw09_13.cpp:51: error: âstuGradesâ was not declared in this scope
hw09_13.cpp:54: error: âstuGradesâ was not declared in this scope
hw09_13.cpp:54: error: âstuâ was not declared in this scope
hw09_13.cpp: In function âdouble getAvg(double (*)[4], int, int)â:
hw09_13.cpp:61: error: âstuGradeâ was not declared in this scope
hw09_13.cpp: At global scope:
hw09_13.cpp:82: error: expected â,â or â...â before âstuNamesâ
hw09_13.cpp: In function âvoid displayGrade(char (*)[21])â:
hw09_13.cpp:89: error: âstuâ was not declared in this scope
hw09_13.cpp:90: error: âstuGradeâ was not declared in this scope
hw09_13.cpp:90: error: ânumâ was not declared in this scope
hw09_13.cpp:93: error: âstuNamesâ was not declared in this scope
#include <iostream>
#include <iomanip>
using namespace std;

char getStuNames(char[][21], int);
double getStuGrades(char[][21], double[][4], int, int);
void displayGrade(char[][21], double[], int, int);


int main() {

    const int stu = 5;
    const int num = 4;
    char stuNames[stu][21];
    double stuGrades[stu][4];

    getStuNames(stuNames, stu);
    getStuGrades(stuNames, stuGrades, stu, num);

    displayGrade(stuNames, stuGrades, stu, num);

    cout << "\n\n\n\n";

    return 0;
}

Red lines need to match each other. stuGrades is a 2-D array, but displayGrades asks for a one dimensional array as its second argument:

void displayGrade(char[][21], double[], int, int);

Perhaps you want this?

void displayGrade(char[][21], double[][4], int, int);
This article has been dead for over six months. Start a new discussion instead.