### 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.
 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778`` `````` #include 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?"<>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?"<>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.