plz friend solve this code for me I dont know what is the wrong with it. it is in c++ programing language.

#include <stdio.h>
#include <string.h>
#define size 20
struct data
{
 int age;
 int year;
 char course[6];
 char name[20];

} students[20];
struct temporary  //changed to struct?
{
 int age;
 int year;
 char course[6];
 char name[20]; 
} holder;

int main()
{
int x,limit;
int input,inputdata,showdata,  sort_asc_by_age;
 do
 {
  //clrscr(); non portable avoid if possible
  puts("1..insert data");
  puts("2..show data");
  puts("3..show data in ascending order by age");
  puts("4..show data in ascending order by year");
  puts("5..show data in descending order by age");
  puts("6..show data in descending order by year");
  puts("9..exit");
  printf("input choice:"); scanf("%d",&input);
  switch(input)
  {
   case 1:
     inputdata();
     break;
   case 2:
     showdata();
     break;
   case 3:
    sort_asc_by_age(); //added this case
    break;             //added this case

  }
 }while(input!=9);

  getchar(); //getchar better than getch()
             //getch is non-portable
 return 0;
}


inputdata()
int limit,x;
printf("Size of structure to make? (1-20)\t");
scanf("%d",&limit);
if(limit<1 || limit>size)
 {
 printf("Input Invalid!");
 }
else
 {
   limit=limit-1;
   printf("\n\n\nAge Year Course  Name\n");

   for(x=0; x<=limit; x++)
   {
    printf("Age:");
    scanf("%d",&students[x].age);
    printf("Year:");
    scanf("%d",&students[x].year);
    printf("Course:");
    scanf("%s",students[x].course); //gets = bad
    printf("Name:");
    scanf("%s",students[x].name); //gets = bad 
    //although scanf is a lesser evil
    //for better a better input tutorial in c
    //check out dave's tutorial
    printf("\nNext entry\n");
   }

  }

showdata()
{
 int limit;
 int x;
 printf("This are the items you inputted!");
 printf("\nAge Year level Course  Name\n");
 for(x=0;x<size;x++)
  {
  printf("%d",students[x].age);
  printf("\t%d",students[x].year);//changed to %d (it is an integer!)
  printf("\t%s",students[x].course);
  printf("\t%s\n",students[x].name);
  }
 getchar(); //getchar better than getch()
}
sort_asc_by_age()
{

int x,y;
for(x = 0; x < size; x++)
    for(y = 0; y < size; y++)
      if(students[y].age > students[y+1].age)
      {
 holder.age=students[y+1].age;
 holder.year=students[y+1].year;
 strcpy(holder.course,students[y+1].course); //changed string copy
 strcpy(holder.name,students[y+1].name);// changed

 students[y+1].age=students[y].age;
 students[y+1].year=students[y].year;
 strcpy(students[y+1].name,students[y].name);//changed
 strcpy(students[y+1].course,students[y].course);//changed

 students[y].age=holder.age;
 students[y].year=holder.year;
 strcpy(students[y].name,holder.name); //changed
 strcpy(students[y].course,holder.course);//changed
       }
  for(x=0;x<size;x++)
  {
  printf("%d",students[x].age);
  printf("\t%d",students[x].year); //%d
  printf("\t%s",students[x].course);
  printf("\t%s\n",students[x].name);
  }
 getch();
}

sort_asc_by_year()
{
int x,y;
for(x = 0; x < size; x++)
    for(y = 0; y < size-1; y++)
      if(students[y].year > students[y+1].age)
 {
 holder.age=students[y+1].age;
 holder.year=students[y+1].year;
 strcpy(holder.course,students[y+1].course); //changed
 strcpy(holder.name,students[y+1].name);//changed

 students[y+1].age=students[y].age;
 students[y+1].year=students[y].year;
 strcpy(students[y+1].name,students[y].name);//changed
 strcpy(students[y+1].course,students[y].course);//changed

 students[y].age=holder.age;
 students[y].year=holder.year;
 strcpy(students[y].name,holder.name); //changed
 strcpy(students[y].course,holder.course);//changed

       }
for(x=0;x<size;x++)
  {
  printf("%d",students[x].age);
  printf("\t%d",students[x].year);  //%d
  printf("\t%s",students[x].course);
  printf("\t%s\n",students[x].name);
  }
 getchar(); //getchar
}

sort__desc_by_age()
{

int x,y;
for(x = 0; x < size; x++)
    for(y = 0; y < size; y++)
      if(students[y].age < students[y+1].age)
      {
 holder.age=students[y+1].age;
 holder.year=students[y+1].year;
 strcpy(holder.course,students[y+1].course); //changed
 strcpy(holder.name,students[y+1].name);//changed

 students[y+1].age=students[y].age;
 students[y+1].year=students[y].year;
 strcpy(students[y+1].name,students[y].name);//changed
 strcpy(students[y+1].course,students[y].course);//changed

 students[y].age=holder.age;
 students[y].year=holder.year;
 strcpy(students[y].name,holder.name); //changed
 strcpy(students[y].course,holder.course);//changed
       }
for(x=0;x<size;x++)
  {
  printf("%d",students[x].age);
  printf("\t%d",students[x].year);  //%d
  printf("\t%s",students[x].course);
  printf("\t%s\n",students[x].name);
  }
 getch();
}
sort_desc_by_year()
{

int x,y;
for(x = 0; x < size; x++)
    for(y = 0; y < size-1; y++)
      if(students[y].year < students[y+1].age)
 {
        holder.age=students[y+1].age;
 holder.year=students[y+1].year;
 strcpy(holder.course,students[y+1].course); //changed
 strcpy(holder.name,students[y+1].name);//changed

 students[y+1].age=students[y].age;
 students[y+1].year=students[y].year;
 strcpy(students[y+1].name,students[y].name);//changed
 strcpy(students[y+1].course,students[y].course);//changed

 students[y].age=holder.age;
 students[y].year=holder.year;
 strcpy(students[y].name,holder.name); //changed
 strcpy(students[y].course,holder.course);//changed
       }
for(x=0;x<size;x++)
  {
  printf("%d",students[x].age);
  printf("\t%d",students[x].year);  //%d
  printf("\t%s",students[x].course);
  printf("\t%s\n",students[x].name);
  }
 getchar(); //getchar()
}

Quickly edited your code to remove errors. This code looks like C code.

#include <stdio.h>
#include <string.h>
#define size 20

void inputdata();
void showdata();
void sort_asc_by_age();
void sort_desc_by_year()

struct data
{
int age;
int year;
char course[6];
char name[20];

} students[20];

struct temporary //changed to struct?
{
int age;
int year;
char course[6];
char name[20];
} holder;

int main()
{

int input;
do
{
//clrscr(); non portable avoid if possible
puts("1..insert data");
puts("2..show data");
puts("3..show data in ascending order by age");
puts("4..show data in ascending order by year");
puts("5..show data in descending order by age");
puts("6..show data in descending order by year");
puts("9..exit");
printf("input choice:"); 
scanf("%d",&input);

switch(input)
{
case 1:
    inputdata();
    break;
case 2:    showdata();
        break;
case 3:sort_asc_by_age(); //added this case
        break; //added this case

}
}while(input!=9);

getchar(); //getchar better than getch()
//getch is non-portable
return 0;
}


void inputdata()
{
int limit,x;
printf("Size of structure to make? (1-20)\t");
scanf("%d",&limit);
if(limit<1 || limit>size)
{
printf("Input Invalid!");
}
else
{
limit=limit-1;
printf("\n\n\nAge Year Course Name\n");

for(x=0; x<=limit; x++)
{
printf("Age:");
scanf("%d",&students[x].age);
printf("Year:");
scanf("%d",&students[x].year);
printf("Course:");
scanf("%s",students[x].course); //gets = bad
printf("Name:");
scanf("%s",students[x].name); //gets = bad
//although scanf is a lesser evil
//for better a better input tutorial in c
//check out dave's tutorial
printf("\nNext entry\n");
}

}
}

void showdata()
{

int x;
printf("This are the items you inputted!");
printf("\nAge Year level Course Name\n");
for(x=0;x<size;x++)
{
printf("%d",students[x].age);
printf("\t%d",students[x].year);//changed to %d (it is an integer!)
printf("\t%s",students[x].course);
printf("\t%s\n",students[x].name);
}
getchar(); //getchar better than getch()
}


void sort_asc_by_age()
{

int x,y;
for(x = 0; x < size; x++)
for(y = 0; y < size; y++)
if(students[y].age > students[y+1].age)
{
holder.age=students[y+1].age;
holder.year=students[y+1].year;
strcpy(holder.course,students[y+1].course); //changed string copy
strcpy(holder.name,students[y+1].name);// changed

students[y+1].age=students[y].age;
students[y+1].year=students[y].year;
strcpy(students[y+1].name,students[y].name);//changed
strcpy(students[y+1].course,students[y].course);//changed

students[y].age=holder.age;
students[y].year=holder.year;
strcpy(students[y].name,holder.name); //changed
strcpy(students[y].course,holder.course);//changed
}
for(x=0;x<size;x++)
{
printf("%d",students[x].age);
printf("\t%d",students[x].year); //%d
printf("\t%s",students[x].course);
printf("\t%s\n",students[x].name);
}

}

void sort_asc_by_year()
{
int x,y;
for(x = 0; x < size; x++)
for(y = 0; y < size-1; y++)
if(students[y].year > students[y+1].age)
{
holder.age=students[y+1].age;
holder.year=students[y+1].year;
strcpy(holder.course,students[y+1].course); //changed
strcpy(holder.name,students[y+1].name);//changed

students[y+1].age=students[y].age;
students[y+1].year=students[y].year;
strcpy(students[y+1].name,students[y].name);//changed
strcpy(students[y+1].course,students[y].course);//changed

students[y].age=holder.age;
students[y].year=holder.year;
strcpy(students[y].name,holder.name); //changed
strcpy(students[y].course,holder.course);//changed

}
for(x=0;x<size;x++)
{
printf("%d",students[x].age);
printf("\t%d",students[x].year); //%d
printf("\t%s",students[x].course);
printf("\t%s\n",students[x].name);
}
getchar(); //getchar

}

void sort__desc_by_age()
{

int x,y;
for(x = 0; x < size; x++)
for(y = 0; y < size; y++)
if(students[y].age < students[y+1].age)
{
holder.age=students[y+1].age;
holder.year=students[y+1].year;
strcpy(holder.course,students[y+1].course); //changed
strcpy(holder.name,students[y+1].name);//changed

students[y+1].age=students[y].age;
students[y+1].year=students[y].year;
strcpy(students[y+1].name,students[y].name);//changed
strcpy(students[y+1].course,students[y].course);//changed

students[y].age=holder.age;
students[y].year=holder.year;
strcpy(students[y].name,holder.name); //changed
strcpy(students[y].course,holder.course);//changed
}
for(x=0;x<size;x++)
{
printf("%d",students[x].age);
printf("\t%d",students[x].year); //%d
printf("\t%s",students[x].course);
printf("\t%s\n",students[x].name);
}

}

void sort_desc_by_year()
{

int x,y;
for(x = 0; x < size; x++)
for(y = 0; y < size-1; y++)
if(students[y].year < students[y+1].age)
{
holder.age=students[y+1].age;
holder.year=students[y+1].year;
strcpy(holder.course,students[y+1].course); //changed
strcpy(holder.name,students[y+1].name);//changed

students[y+1].age=students[y].age;
students[y+1].year=students[y].year;
strcpy(students[y+1].name,students[y].name);//changed
strcpy(students[y+1].course,students[y].course);//changed

students[y].age=holder.age;
students[y].year=holder.year;
strcpy(students[y].name,holder.name); //changed
strcpy(students[y].course,holder.course);//changed
}
for(x=0;x<size;x++)
{
printf("%d",students[x].age);
printf("\t%d",students[x].year); //%d
printf("\t%s",students[x].course);
printf("\t%s\n",students[x].name);
}
getchar(); //getchar()
}

thank u my friend but I still find to error

--------------------Configuration: zz - Win32 Debug--------------------
Compiling...
zz.cpp
c:\documents and settings\user\c++\zz.cpp(11) : error C2143: syntax error : missing ';' before '<class-head>'
c:\documents and settings\user\c++\zz.cpp(11) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
zz.exe - 2 error(s), 0 warning(s)

thank u my friend but I still find to error

--------------------Configuration: zz - Win32 Debug--------------------
Compiling...
zz.cpp
c:\documents and settings\user\c++\zz.cpp(11) : error C2143: syntax error : missing ';' before '<class-head>'
c:\documents and settings\user\c++\zz.cpp(11) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
zz.exe - 2 error(s), 0 warning(s)

#include <stdio.h>
#include <string.h>
#define size 20

void inputdata(void);
void showdata(void);
void sort_asc_by_age(void);
void sort_asc_by_year(void);
void sort_desc_by_age(void);
void sort_desc_by_year(void);

struct data
{
   int age;
   int year;
   char course[6];
   char name[20];

} students[20];
struct temporary //changed to struct?
{
   int age;
   int year;
   char course[6];
   char name[20];
} holder;

int main()
{
   int x,limit;
   int input;
   do
   {
      //clrscr(); non portable avoid if possible
      puts("1..insert data");
      puts("2..show data");
      puts("3..show data in ascending order by age");
      puts("4..show data in ascending order by year");
      puts("5..show data in descending order by age");
      puts("6..show data in descending order by year");
      puts("9..exit");
      printf("input choice:"); scanf("%d",&input);
      switch(input)
      {
      case 1:
         inputdata();
         break;
      case 2:
         showdata();
         break;
      case 3:
         sort_asc_by_age(); //added this case
         break; //added this case
      
      }
   }while(input!=9);
   
   getchar(); //getchar better than getch()
   //getch is non-portable
   return 0;
   }
   
   
void inputdata(void)
{
   int limit,x;
   printf("Size of structure to make? (1-20)\t");
   scanf("%d",&limit);
   if(limit<1 || limit>size)
   {
      printf("Input Invalid!");
   }
   else
   {
      limit=limit-1;
      printf("\n\n\nAge Year Course Name\n");
   }
   
   for(x=0; x<=limit; x++)
   {
      printf("Age:");
      scanf("%d",&students[x].age);
      printf("Year:");
      scanf("%d",&students[x].year);
      printf("Course:");
      scanf("%s",students[x].course); //gets = bad
      printf("Name:");
      scanf("%s",students[x].name); //gets = bad
      //although scanf is a lesser evil
      //for better a better input tutorial in c
      //check out dave's tutorial
      printf("\nNext entry\n");
   }
   
}

void showdata(void)
{
   int limit;
   int x;
   printf("This are the items you inputted!");
   printf("\nAge Year level Course Name\n");
   for(x=0;x<size;x++)
   {
      printf("%d",students[x].age);
      printf("\t%d",students[x].year);//changed to %d (it is an integer!)
      printf("\t%s",students[x].course);
      printf("\t%s\n",students[x].name);
   }
   getchar(); //getchar better than getch()
}
void sort_asc_by_age(void)
{

   int x,y;
   for(x = 0; x < size; x++)
   for(y = 0; y < size; y++)
   if(students[y].age > students[y+1].age)
   {
      holder.age=students[y+1].age;
      holder.year=students[y+1].year;
      strcpy(holder.course,students[y+1].course); //changed string copy
      strcpy(holder.name,students[y+1].name);// changed
      
      students[y+1].age=students[y].age;
      students[y+1].year=students[y].year;
      strcpy(students[y+1].name,students[y].name);//changed
      strcpy(students[y+1].course,students[y].course);//changed
      
      students[y].age=holder.age;
      students[y].year=holder.year;
      strcpy(students[y].name,holder.name); //changed
      strcpy(students[y].course,holder.course);//changed
   }
   for(x=0;x<size;x++)
   {
      printf("%d",students[x].age);
      printf("\t%d",students[x].year); //%d
      printf("\t%s",students[x].course);
      printf("\t%s\n",students[x].name);
   }
   getchar(); //getchar better than getch()    
}

void sort_asc_by_year(void)
{
   int x,y;
   for(x = 0; x < size; x++)
   for(y = 0; y < size-1; y++)
   if(students[y].year > students[y+1].age)
   {
      holder.age=students[y+1].age;
      holder.year=students[y+1].year;
      strcpy(holder.course,students[y+1].course); //changed
      strcpy(holder.name,students[y+1].name);//changed
      
      students[y+1].age=students[y].age;
      students[y+1].year=students[y].year;
      strcpy(students[y+1].name,students[y].name);//changed
      strcpy(students[y+1].course,students[y].course);//changed
      
      students[y].age=holder.age;
      students[y].year=holder.year;
      strcpy(students[y].name,holder.name); //changed
      strcpy(students[y].course,holder.course);//changed
   
   }
   for(x=0;x<size;x++)
   {
      printf("%d",students[x].age);
      printf("\t%d",students[x].year); //%d
      printf("\t%s",students[x].course);
      printf("\t%s\n",students[x].name);
   }
   getchar(); //getchar
}

void sort_desc_by_age(void)
{

   int x,y;
   for(x = 0; x < size; x++)
   for(y = 0; y < size; y++)
   if(students[y].age < students[y+1].age)
   {
      holder.age=students[y+1].age;
      holder.year=students[y+1].year;
      strcpy(holder.course,students[y+1].course); //changed
      strcpy(holder.name,students[y+1].name);//changed
      
      students[y+1].age=students[y].age;
      students[y+1].year=students[y].year;
      strcpy(students[y+1].name,students[y].name);//changed
      strcpy(students[y+1].course,students[y].course);//changed
      
      students[y].age=holder.age;
      students[y].year=holder.year;
      strcpy(students[y].name,holder.name); //changed
      strcpy(students[y].course,holder.course);//changed
   }
   for(x=0;x<size;x++)
   {
      printf("%d",students[x].age);
      printf("\t%d",students[x].year); //%d
      printf("\t%s",students[x].course);
      printf("\t%s\n",students[x].name);
   }
   getchar(); //getchar better than getch()    
}
void sort_desc_by_year(void)
{

   int x,y;
   for(x = 0; x < size; x++)
   for(y = 0; y < size-1; y++)
      if(students[y].year < students[y+1].age)
      {
         holder.age=students[y+1].age;
         holder.year=students[y+1].year;
         strcpy(holder.course,students[y+1].course); //changed
         strcpy(holder.name,students[y+1].name);//changed
         
         students[y+1].age=students[y].age;
         students[y+1].year=students[y].year;
         strcpy(students[y+1].name,students[y].name);//changed
         strcpy(students[y+1].course,students[y].course);//changed
         
         students[y].age=holder.age;
         students[y].year=holder.year;
         strcpy(students[y].name,holder.name); //changed
         strcpy(students[y].course,holder.course);//changed
      }
   for(x=0;x<size;x++)
   {
      printf("%d",students[x].age);
      printf("\t%d",students[x].year); //%d
      printf("\t%s",students[x].course);
      printf("\t%s\n",students[x].name);
   }
   getchar(); //getchar()
}

just modified to compile

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.