Can you guys what is wrong here?

On codeblocks it says:

|In function 'void highestScore(int)':|
|76|warning: statement has no effect [-Wunused-value]|
|80|warning: statement has no effect [-Wunused-value]|
|In function 'void highestStudent(int)':|
|90|error: ISO C++ forbids comparison between pointer and integer [-fpermissive]|


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#include <iostream>
#include <string>
using namespace std;
struct sData //Store info for students.
{
    string fName;
    string lName;
    int tScore;
    char sGrade;
};
void studentInfo (); //User input info for students.
char studentGrade (int); //Assigns letter based on test score.
void highestScore (int); //Finds the highest score.
void highestStudent (int); //Finds the students with the highest score.
void output (); //Outputs all the user input.

sData student[20];
int highest_score[20], highest;

int main ()
{
    studentInfo();
    highestStudent(highest);
    output();
    return 0;
}
void studentInfo ()
{
    for (int x=0;x<20;x++){
        cout<<"Student #"<<x+1<<endl;
        cout<<"First Name: ";
        cin>>student[x].fName;
        cout<<"Last Name: ";
        cin>>student[x].lName;
        cout<<"Test Score: ";
        cin>>student[x].tScore;
        if ((student[x].tScore >= 0)&&(student[x].tScore <= 100)){
            student[x].sGrade = studentGrade(student[x].tScore);
            }
        else {
            do {
                cout<<"Invalid Score. Enter again."<<endl;
                cout<<"Test Score: ";
                cin>>student[x].tScore;
            }while (student[x].tScore < 0 || student[x].tScore > 100);
            student[x].sGrade = studentGrade(student[x].tScore);
        }
        cout<<"\n";
        highestScore(x);
    }
}
char studentGrade(int n)
{
    char letter;
    if (n >= 90){
        letter = 'A';
    }
    if ((n <= 89)&&(n >= 80)){
        letter = 'B';
    }
    if ((n <= 79)&&(n >= 70)){
        letter = 'C';
    }
    if ((n <= 69)&&(n >= 65)){
        letter = 'D';
    }
    if (n<65){
        letter = 'F';
    }
    return letter;
}
void highestScore(int y)
{
    for(int y=0;y<20;y++){
    if (y == 0){
        highest_score[0] == student[y].tScore;
        highest = student[y].tScore;
    }
    if (student[y].tScore > highest){
        highest_score[y] == student[y].tScore;
        highest = student[y].tScore;
    }
    }
}
void highestStudent(int z)
{
    cout<<"Highest Test Score: "<<z<<endl;
    cout<<"Student with the highest score are: "<<endl;
    for (int a=0;a<20;a++){
        if (highest_score == z){
            cout<<student[a].lName<<", "<<student[a].fName<<endl;
        }
    }

}
void output ()
{
    cout<<"Last Name"<<"  First Name"<<"\t\tTest Score"<<"\tGrade"<<endl;
    for (int m=0;m<20;m++){
        cout<<student[m].lName<<", "<<student[m].fName<<" \t\t\t "<<student[m].tScore<<" \t\t "<<student[m].sGrade<<endl;
    }
}
highest_score[0] == student[y].tScore; compares to see if highest_score[0] is equal to student[y].tScore;. If you want to assign the value of student[y].tScore; to highest_score[0] you should instead use the = operator.

On line 90 you get an error because you are comparing an array with an integer.
Thanks Peter87.

Now my problem is to output in a tabular form and I dont know how. :/
Topic archived. No new replies allowed.