fix please

after i compiled, this message was appear.

/var/tmp/ccKyPeru.o: In function `main':
main.cpp:(.text.startup+0x17b): undefined reference to `newCGPA()'
main.cpp:(.text.startup+0x1a6): undefined reference to `currentCGPA()'
main.cpp:(.text.startup+0x1cb): undefined reference to `previousCGPA()'
collect2: error: ld returned 1 exit status

can someone help me fix this coding?
i need to create cgpa calculate application. the application may able to calculate previous cgpa and current cgpa. and the program must include funtion, selection, looping, array, struct/pointer.

#include<iostream>
using namespace std;

//declare prototype
void previousinfo();
void currentinfo();
void previousCGPA();
void currentCGPA();
void newCGPA();
void previousgrade();
void currentgrade();
void currentcredit();

//global declaration
char another;
string name,matric,sub_code,sub_name,pre_grade,cur_grade;
float credit[5], point[5];
float total_Pre_P, total_Pre_C, total_Cur_P, total_Cur_C, totalP, totalC;
int i,a;

int main()
{
int menu;
cout << "Created by: Liyana,Iz'zati,Anis" << endl
<< "==========================================================" << endl
<< "== CGPA CALCULATE APPLICATION ==" << endl
<< "== ============================ ==" << endl
<< "== 1. Input Previous Student Info ==" << endl
<< "== 2. Input Current Student Info ==" << endl
<< "== 3. Calculate Previous CGPA ==" << endl
<< "== 4. Calculate Current CGPA ==" << endl
<< "== 5. Calculate new CGPA ==" << endl
<< "==========================================================" << endl;
sub:
cout<<"Enter your choice: ";
cin>>menu;
switch(menu)//select one of choice
{
case 1:
cout<<"1.Previous Student Info"<<endl;
previousinfo();
break;

case 2:
cout<<"2.Current Student Info"<<endl;
currentinfo();
break;

case 3:
cout<<"3.Calculate Previous CGPA "<<endl;
previousCGPA();
break;

case 4:
cout<<"4.Calculate Current CGPA"<<endl;
currentCGPA();
break;

case 5:
cout<<"5.Calculate New CGPA"<<endl;
newCGPA();
break;

default:
cout<<"You have entered wrong input\n"<<endl;
goto sub;
break;
}
}
void previousinfo()
{

cout<<"\nStudent Name: ";
cin.ignore();
getline(cin, name);
cout<<"Matric No.: ";
cin.ignore();
getline(cin,matric);
cout<<"\nPREVIOUS STUDENT INFO."<<endl;

for (i=1; i<=4; i++)
{
cout<<"Enter Subject Name: ";
cin>>sub_name;
cout<<"Enter Subject Code: ";
cin>>sub_code;
cout<<"Enter Credit Hours: ";
cin>>credit[i];
cout<<"Enter Grade Point ";
cin>>point[i];
cout<<"\n";
}
}
void currentinfo(){

cout<<"\nCURRENT STUDENT INFO."<<endl;

for (a=1; a<=4; a++)
{
cout<<"Enter Subject Name: ";
cin>>sub_name;
cout<<"Enter Subject Code: ";
cin>>sub_code;
cout<<"Enter Credit Hours: ";
cin>>credit[a];
cout<<"Enter Grade Point ";
cin>>point[a];
cout<<"\n";
}
}
void previousgrade(int i){
total_Pre_P=point[1]+point[2]+point[3]+point[4];
total_Pre_C=credit[1]+credit[2]+credit[3]+credit[4];
cout<<"Total Previous Point: "<<total_Pre_P;
cout<<"\nTotal Previous Credit: "<<total_Pre_C;
cout<<"\nPrevious CGPA: "<<total_Pre_P/total_Pre_C;
cout<<"\n\n";
}
void currentgrade(int a){
total_Cur_P=point[1]+point[2]+point[3]+point[4];
total_Cur_C=credit[1]+credit[2]+credit[3]+credit[4];
cout<<"\nTotal Current Point: "<<total_Cur_P;
cout<<"\nTotal Current Credit: "<<total_Cur_C;
cout<<"\nCurrent Grade Points: "<<total_Cur_P*total_Cur_C;
cout<<"\n";
}
void currentcredit(float total_Cur_C){
total_Cur_C=credit[1]+credit[2]+credit[3]+credit[4];
cout<<"\nTotal Current Credit: "<<total_Cur_C;
}
void currentCGPA(float total_Cur_P,float total_Cur_C){
cout<<"\nCurrent CGPA "<<total_Cur_P/total_Cur_C;
}
void newCGPA(float total_Cur_P,float total_Cur_C,float total_Pre_C, float total_Pre_P){
totalP=total_Pre_P+total_Cur_P;
totalC=total_Pre_C+total_Cur_C;

cout<<"\nTotal All Point: "<<totalP;
cout<<"\nTotal All Credit: "<<totalC;
cout<<"\n";
cout<<"\nNew CGPA (Total All Point / Total All Credit) = "<<totalP/totalC<<endl;
cout<<"\n";
cout<<"Calculate for another student (Y/N): ";
cin>>another;
}

1
2
3
4
case 5:
cout<<"5.Calculate New CGPA"<<endl;
newCGPA();
break;


On the third line there, you're trying to call the function newCGPA(). That function does not exist. You cannot call functions that don't exist.

Looks like you do have this function:
void newCGPA(float total_Cur_P,float total_Cur_C,float total_Pre_C, float total_Pre_P)
but that's not the same as
newCGPA()

Can you see the difference?
Topic archived. No new replies allowed.