Click here to Skip to main content
15,905,683 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
i have written this c++ program for find max , and sorting .... it has one error which i can't find why it doesn't compile ... please forward me in its compiling ....

C++
#include <iostream>
using namespace std;
#include <string.h>
#include <stdio.h>
// #include <conio.h>
#include <stdlib.h>
#include <cstring.h>

  void swapname( char nam1[] , char nam2[])
{
    char tempname[50]
	strcpy (tempname , nam1);
	strcpy (nam1 , nam2);
	strcpy (nam2 , tempname);
	
}
 void swapnumbers(float *num1 , float *num2)
{
    float tempnum;
	tempnum = *num1;
	*num1 = *num2;
	*num2 = tempnum;
}

int main ()
{
  char nam[5][50];
  int id [5];
  float grade[5];
  int level[5] , i , j , location , rotbeh;
  float max;
  system ("cls");
  for(i=0 ; i<5 ; i++)
  {
	  cout << " Enter a name " << i << " and a family : \n " ;
	  cin.getline(nam[i],50);

	  cout << " Enter An ID : \n " ;
	  cin >> id[i];

	  cout << "Enter a grade :" ;
	  cin >> grade[i];
	      
  }

  for (i=0 ; i<4 ; i++)
  { 
	  max = garde [i] ; location = i;
	  for( j=i+1 ; j<5 ; j++)
		  if (grade[j] > max)
		  { 
			  max = grade[j] ; location = j ;
		  }
		  swapname ( nam[i], nam[location]);
		  swapnumbers(&grade[i] , &grade[location]);
  }

  rotbeh = 1 ; level[0] = rotbeh ;
  for (i=1 ; i<5 ; i++)
  {
	  if(grade[i] != grade[i-1])
		  rotbeh = i;
	      level[i] = rotbeh ;
  }
  for ( i=0 ; i<5 ; i++)
  {
	  cout <<  nam[i] ;
      cout << grade[i] ;
      cout << level[i];

  }

  return 0;
}
Posted
Updated 28-Jun-12 20:06pm
v2
Comments
[no name] 29-Jun-12 2:11am    
You have just dumped your code here for someone to fix. No info about compile errors or whatever. This shows a lack of respect for those who may take the time to help you.
Sandeep Mewara 29-Jun-12 3:21am    
virtual 5!
OriginalGriff 29-Jun-12 2:14am    
Where is the error?
What is the error?
What have you got against comments?
These are all questions that need to be answers, young padawan!
lida zar 29-Jun-12 3:25am    
the error is for swapnam
OriginalGriff 29-Jun-12 3:35am    
Which line?
What error message?
Please, try to help us to help you - remember that we can't see your screen, access your HDD, or read your mind! :laugh:

1 solution

Add a semicolon to the first line in swapnam:
C#
void swapname( char nam1[] , char nam2[])
{
    char tempname[50]
Becomes
C#
void swapname( char nam1[] , char nam2[])
{
    char tempname[50];
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900