Too many arguements

Every time I try to compile my code I keep getting an error stating that there are too many arguments in my function and I don't understand what that means or what to do.

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

#include <iostream>

using namespace std;

double average();

int findLowest();

void findLetter();



int main()
{
    int x, y, z;

    cout<<"please enter three grades"<<endl;

    cin>>x>>y>>z;

    average(x, y, z);
    return 0;

}

double average(int x, int y, int z)
{

    double a = (x+y+z) / 3;

    return a;
}


the problem is that your average prototype does not define three ints like your declaration

your code should be

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


#include <iostream>

using namespace std;

double average(int,int,int); // fixed:  error was here 

int findLowest();

void findLetter();



int main()
{
    int x, y, z;

    cout<<"please enter three grades"<<endl;

    cin>>x>>y>>z;

    average(x, y, z);
    return 0;

}

double average(int x, int y, int z)
{

    double a = (x+y+z) / 3;

    return a;
}

Last edited on
Line 6: Your function prototype for average() says it takes no parameters.

Line 22: You call average() with three parameters. Your call must agree with the function prototype.

Change your function prototype so that is agrees with line 27.


Topic archived. No new replies allowed.