Not declared in scope...

I have wrote a simple average calculation program trying to calculate a semester average. When I compile the code I get an error telling me my 'inputExam' function was not declared in this scope. I've researched the error message and I can't figure out what to do to fix it.

I also get this error for the other functions, but once I understand my error I think I can fix the others.
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
  #include <iostream>

using namespace std;

int main()
{
    double finalExam=0.0;
    double midterm = 0.0;
    double quizzes = 0.0;
    double labs = 0.0;
    double semGrade=0.0;

    midterm=inputExam("Midterm");
    finalExam=inputExam("Final");
    quizzes=inputAndAvgQuizzes();
    labs=inputAndAvgLabs();

    semGrade=(midterm*.2)+(finalExam*.2)+(labs*.5)+(quizzes*.1);

    cout<<"Your End of Semester Grade is: " semGrade;

    return 0;
}

double inputExam(string examType)
{
    double grade;
    cout<< "Enter the " examType " Score: ";
    cin>>grade;
    return (grade);
}

double inputAndAvgLabs()
{
    double num [4];
    double sum;
    double avg;

    if (int a=0, a<3,a++)
    {
        cout<<"What is the grade?"<<endl;
        cin>>num[a]>>endl;
    }
    if (int a=0, a<3, a++)
    {
        sum=sum+num[a];
    }
    avg=sum/4;

    return avg;
}

double inputAndAvgQuizzes()
{
    double num[3];
    double sum;
    double avg;
    double lowest = num[0];

    if (int a=0, a<2,a++)
    {
        cout<<"What is the grade?"<<endl;
        cin>>num[a]>>endl;
    }

    if (lowest>num[1])
    {
        lowest=num[1];
    }
    if (lowest>num[2])
    {
        lowest=num[2];
    }
    sum=num[1]+num[2]+num[3]-lowest;
    avg=sum/2;

    return avg;
}
You need a forward declaration.

Andy

http://en.wikipedia.org/wiki/Forward_declaration
Declare the functions before main...
The computer doesn't know these functions exist you have to tell it before you call it...
Either move all your other functions before int main()
Or
Declare them before main (suggested)
Topic archived. No new replies allowed.