my code is giving linking errors can anyone help!

This is a discussion on my code is giving linking errors can anyone help! within the C++ Programming forums, part of the General Programming Boards category; Code: Code: //*Hira Daud // regn no=83 //BICSE 4-A*/ #include<iostream> #include<string> using namespace std; struct student { float sum; float ...

  1. #1
    Registered User
    Join Date
    Dec 2006
    Posts
    8

    my code is giving linking errors can anyone help!

    Code:
    Code:
    //*Hira Daud
    // regn no=83
    //BICSE 4-A*/ 
    
    
    
    
    #include<iostream>
    #include<string>
    using namespace std;
    
    struct student
    {
    	float sum;
        float  numbgrade;
    	char course;
    	char section_number;
        double reg_no;
    	string name;
    	int progass[4];
    	int test[4];
    	int homeass[4];
    	float progav;
    	float testav;
    	float homeav;
    
    };
    
    void swap(int *,int *);
     bool  ascending(int ,int );
    void bubble(float ,const int size,bool   (*compare)(int,int));
    void lettergrade(float *);    //prototypes 
          
    int main()
    {
    	double testwgt,homewgt,progwgt;
    	testwgt=0.6;
    	homewgt=0.2;
    	progwgt=0.2;
    
    
      const int a=40;
      student student1[a];
      for (int i=0;i<a;i++)
      {
    	  cout<<"please enter your name\t:";
    	 
    	  cin>>student1[i].name;
    	
    	  cout<<"\nenter your section number\t:";
    	  cin>>student1[i].section_number;
    	  
    	  cout<<"\nenter your registration number\t:";
    	  cin>>student1[i].reg_no;
    	  
    	  cout<<"plz enter ur crs identifier\n";
    	  cin>>student1[i].course;
    	  
    	   
      
    student1[i].testav=student1[i].progav=student1[i].homeav=student1[i].sum=0; //initializing
       for(int j=0;j<4;j++)
       {
    	  cout<<"enter the marks of ur tests\n";
    	  cin>>student1[i].test[j];
    	  student1[i].testav+=student1[i].test[j];
    
    	  cout<<"enter the marks of ur programming asssignments\t\n";
    	  cin>>student1[i].progass[j];
    	  student1[i].progav+=student1[i].progass[j];
    
    	  cout<<"enter the marks of ur home assignments\n\t";
    	  cin>>student1[i].homeass[j];
    	  student1[i].homeav+=student1[i].homeass[j];
       }//end of the nested loop
       
      student1[i].testav/=4;
    
      student1[i].homeav/=4;
    
      student1[i].progav/=4;
    
      student1[i].sum = student1[i].testav+student1[i].progav+student1[i].homeav;
    
      if(student1[i].sum>1)
     	  cout<<"there s some error"<<endl;
     else
    	  cout<<"calculate the numeric grade"<<endl;
      
      for(int i=0;i<40;i++)
      {
      
    student1[i].numbgrade=testwgt*student1[i].testav+progwgt*student1[i].progav+homewgt*student1[i].homeav;
      lettergrade(&student1[i].numbgrade);
      }
    
     }//end of for loop
      bubble(student1[i].numbgrade,a,ascending);
    
      cout<<"the highest numeric grade achieved by the student\n"<<student1[39].numbgrade<<endl;
      cout<<"the lowest grade is\n"<<student1[0].numbgrade;
    
    return 0;
    }
    
    
      void lettergrade(float *grade)
      {
    	  if(*grade>93&&*grade<100)
    		  cout<<"ur grade s A"<<endl;
    	  else if (*grade>85&&*grade<92)
    		  cout<<"ur grade s B"<<endl;
    	  else if(*grade>77&&*grade<84)
    		  cout<<"ur grade s C"<<endl;
    	  else if(*grade>70&&*grade<76)
    		  cout<<"ur grade s D"<<endl;
    	  else 
    		  cout<<"ur fail"<<endl;
      }
      //function definition for calculating the letter grade
    
    
    void bubble(int stud[],const int size,bool (*compare)(int,int))
    {
    	for  (int a=1;a<size;a++)
    	{
    		for(int b=0;b<size-1;b++)
    			if((*compare)(stud[b],stud[b+1]))
    				swap(&stud[b], &stud[b+1]);
    	}
    	
    }
    void swap(int *c,int *d)
    {
    	int hold=*c;
    	*c=*d;
    	*d=hold;
    }
    
    
    bool ascending(int p,int q)
    {
    	return q<p;
    }
    Last edited by Salem; 06-09-2007 at 12:30 AM. Reason: remove tagging crazyness

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    what is the error?

  3. #3
    Registered User
    Join Date
    Jan 2005
    Posts
    7,317
    The prototype for bubble doesn't seem to match the definition.

  4. #4
    Registered User
    Join Date
    Dec 2006
    Posts
    8
    can you please indicate what is wrong with prototype ! i am still unable to execute the code

  5. #5
    The larch
    Join Date
    May 2006
    Posts
    3,573
    Code:
    void bubble(float ,const int size,bool   (*compare)(int,int))
    void bubble(int stud[],const int size,bool (*compare)(int,int))
    
    bubble(student1[i].numbgrade,a,ascending);
    See any difference?
    No idea what you mean by sorting one float.
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  6. #6
    Registered User pronecracker's Avatar
    Join Date
    Oct 2006
    Location
    netherlands
    Posts
    158
    I guess it's not your own code.
    Don't call me stupid.

  7. #7
    Registered User
    Join Date
    Dec 2006
    Posts
    8
    yes you are right it is my friend code can you please help then !
    sorry for saying that it my code! i write it my code by mistake

  8. #8
    Registered User
    Join Date
    Jan 2005
    Posts
    7,317
    The prototype and definition must match. That's all you have to do is make them match to fix that specific error.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linking errors
    By Zeeshan in forum C++ Programming
    Replies: 1
    Last Post: 02-22-2009, 01:10 AM
  2. Linking errors with static var
    By Elysia in forum C++ Programming
    Replies: 8
    Last Post: 10-27-2007, 05:24 PM
  3. True ASM vs. Fake ASM ????
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 04-02-2003, 03:28 AM
  4. RAM/Swap Memory Code Errors
    By ghe1 in forum Linux Programming
    Replies: 2
    Last Post: 04-01-2002, 06:37 AM
  5. << !! Posting Code? Read this First !! >>
    By biosx in forum C++ Programming
    Replies: 1
    Last Post: 03-20-2002, 11:51 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21