#include <iostream>
using namespace std;


struct student

{

 char name [50];
 char   S_code [5];
 int fees;
};


 void display(struct student);
 double input(struct student&);

  int main()

{

   double total;
   student stu;
   total=input(stu);
   display(stu);
   input(stu);





   return 0;
}


  double input (struct student&stu )
 {

 double total=0;
  char again ='y';
  cin.getline (stu.name,50);

 while (again =='y');


 {
   cin>>stu.S_code>>stu.fees;

   total=total+stu.fees;

   cin>>again;
 }


 return total;
 }

void display(struct student stu,double totalfees)
{
cout<<"total fee for"<<stu.name<<"is"<<totalfees<<endl;

}

correct the parameters of the display function to match the one in main and it's function prototype

thanks n i still dont get u sorry example pls?

she means that the parameters on line 15 and line 58 do not match. They have to be the same. Also, its best to always pass structures around by reference, never by value, because the program has to duplicate everything in the structure when it is passed by value. You are doing that for the input function, but not for the display function. Passing by value takes CPU time and can slow down your program. Of course it won't be noticeable in simple programs like you are writing, but it will have a performance hit on large programs. So you should get into the habbit of passing structures/classes around by reference now so that you don't have to unlearn bad habbits later on.

15. void display(student stu, double totalfees);
25. display(stu, total);

thanks guys i have fix the bugs but it is not displaying anything....

include <iostream>

using namespace std;

struct student

{

char name [50];
char S_code [5];
int fees;
};

void display(student stu, double totalfees);
double input(struct student&);

int main()
{
double total;
student stu;
total=input(stu);
display(stu, total);
input(stu);
system("Pause");

return 0;
}

double input (struct student &stu )
{

double total=0;
char again ='y';
cin.getline (stu.name,50);

while (again =='y');

{
cin>>stu.S_code>>stu.fees;

total=total+stu.fees;

cin>>again;
}

return total;
}

void display(struct student stu,double totalfees)

{
cout<<"total fee for"<<stu.name<<"is"<<totalfees<<endl;
}

include <iostream>
using namespace std;

struct student
{
char name [50];
char S_code [5];
int fees;
};

void display(student stu, double totalfees);
double input(student&);

int main()
{
double total;
student stu;
total=input(stu);
display(stu, total);
return 0;
}

double input (student & stu)
{
double total=0;
char again ='y';
while (again == 'y')
{
cout << "Input name: ";
cin >> stu.name;
cout << "Input code and fees: ";
cin>>stu.S_code>>stu.fees;
total=total+stu.fees;
cout << "Again? Y/n: ";
cin >> again;
}
return total;
}

void display(student stu,double totalfees)
{
cout<<"total fee for "<<stu.name<<" is "<<totalfees<<endl;
}

Output:

./stu
Input name: Olivia
Input code and fees: 77
7
Again? Y/n: y
Input name: Bob
Input code and fees: 45
7
Again? Y/n: y
Input name: Conway
Input code and fees: 99
7
Again? Y/n: n
total fee for Conway is 21

Enjoy.

commented: giving too much code away -1

thanks alot..................u r very heplfull....................

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.