#include <iostream>
using namespace std;
int grade(char [][5], int);
int main()
{
    int tests, i,j;
    cout << "How many tests?"; cin >> tests;
    char answers[tests][5];
    cout << "What were the answers for all the tests (T/F)?";
    for (i=0;i<tests;i++)
        for (j=0;j<5;j++) cin >> answers[i][j];;
    int g[tests] = {grade(answers, tests)};
    for (i=1;i<=tests;i++)
    {
        cout << "\n   Test " << i << ": ";
        cout << g[i-1] << " out of 25";
    }
    cout << endl;
    return 0;
}
int grade(char ans[][5], int test)
{
    int k, l;
    int gr[test]={0};
    char sheet[5] = {'T', 'T', 'F', 'F', 'T'}; cout << sheet[1];
    for (k=0;k<test;k++)
            for (l=0;l<5;l++)
                    if (ans[k][l]==sheet[l]) gr[k]+= 5;;;
    return *gr;
}
I can't figure out why my program is so inconsistent. If I input T T F F T for the first test, everything turns out fine, but if I have any "wrong answers" for the first test, the values of my g array seem to always be 0.
Any ideas? Thanks!
 
    