Write a C++ Program demonstrating nested structure

//To Enter Few Records and to sort according to the choice of
//the data member. (USING NESTED STRUCTURE)

#include
#include
#include

//GLOBAL DECLARATION OF STRUCTURE
struct date
{
int year,month,day;
};

struct person
{
int recno;
char name[20];
date dob; //using date structure as datatype
int salary;
};

void line(void); //Global Declaration of function as it is called in another function other than main.


void main()
{
void starting(void);
void sorting(struct person[],int);
void display(struct person[]);
void end(void);
person rec[5]; //Declaration of person datatype

starting();

textcolor(111);
textbackground(196);
clrscr();
cout<<"\n\n"<<<"RECORD INFORMATION"; //for inserting records cout<<"\n\n\n\n\tEnter 5 Records\n\n\n\n"; for(int i=0,c=1;i<5;i++)><<<"\n\nEnter Record Number:-"; cin>>rec[i].recno;
cout<<"Enter Name :-"; cin>>rec[i].name;
cout<<"\nFOR Birth_Date\n"; cout<<"--------------\n"; cout<<"Enter Year:-"; cin>>rec[i].dob.year;
cout<<"Enter Month:-"; cin>>rec[i].dob.month;
cout<<"Enter Day:-"; cin>>rec[i].dob.day;
cout<<"\nEnter salary:-"; cin>>rec[i].salary;
line();
cout<<<<<<<<"\n\nWhat Operation Would you Like to Perform\n"; cout<<"1) sort by Record Number\n"; cout<<"2) sort by Name\n"; cout<<"3) sort by Date\n"; cout<<"4) sort by Salary\n"; cout<<"5) DISPLAYING\n"; cout<<"6) QUIT\n"; cout<<"Enter Your Choice:-"; cin>>choice;
switch(choice)
{
case 1:
case 2:
case 3:
case 4:sorting(rec,choice);
break;
case 5:display(rec);
break;
case 6:goto out;
default:cout<<"Entered Choice is Invalid, Try Again"; } getch(); clrscr(); }while(1); out: } //sorting function void sorting(struct person rec[],int choice) { struct person tempq; //record Number wise Sorting if(choice==1) { for(int i=0;i<5;i++) j="i+1;j<5;j++)"> rec[j].recno)
{
tempq = rec[i];
rec[i] = rec[j];
rec[j] = tempq;
}
}
}
}


//namewise sorting

if(choice==2)
{
for(int i=0;i<5;i++) j="i+1;j<5;j++)">0)
{
tempq = rec[i];
rec[i] = rec[j];
rec[j] = tempq;
}
}
}
}

//datewise
if(choice==3)
{
for(int i=0;i<5;i++) j="i+1;j<5;j++)"> rec[j].dob.year)
{
tempq = rec[i];
rec[i] = rec[j];
rec[j] = tempq;

if(rec[i].dob.month > rec[j].dob.month)
{
tempq = rec[i];
rec[i] = rec[j];
rec[j] = tempq;

if(rec[i].dob.day > rec[j].dob.day)
{
tempq = rec[i];
rec[i] = rec[j];
rec[j] = tempq;
}

}
}
}
}
}


//for salary wise

if(choice==4)
{
for(int i=0;i<5;i++) j="i+1;j<5;j++)"> rec[j].salary)
{
tempq = rec[i];
rec[i] = rec[j];
rec[j] = tempq;
}
}
}
}

}



//display function
void display(struct person rec[])
{
textcolor(106);
textbackground(104);
clrscr();
cout<<<
line();
cout<<<"Record No."<<<"NAME OF PERON"<<<"DATE OF BIRTH"<<<"SALARY AT PRESENT"<
line();
for(int i=0;i<5;i++)
{
cout<
cout<<
cout<<
cout<<<<"\\"<<<"\\"<
cout<<
cout<
}
getch();
}


//Line function
void line(void)
{
for(int i=0;i<40;i++)
{
cout<<"--";
}
cout<
}


//Starting function
void starting(void)
{
//START OF programer details\\
textcolor(105);
textbackground(104);
clrscr();
cout<
cout<<"|";
for(int i=0;i<39;i++)
{
cout<<"--";
}
cout<<"|";

cout<<" ";
for(int i=0;i<34;i++)
cout<<"=";

cout<<"VIVEK PATEL";

for(int i=0;i<33;i++)
cout<<"=";

cout<

cout<<"|";
for(int i=0;i<39;i++)
{
cout<<"--";
}
cout<<"|";
cout<<<
line();
cout<<<"WELLCOME VIEWERS\n";
line();
cout<<<"SAMPLE DATABASE APPLICATION\n\n";
line();
line();
cout<<<"Created By VIVEK PATEL\n\n";
line();
line();
cout<<<"EMAIL US AT VIVEK_P9@HOTMAIL.COM";
getch();

//END OF PROGRAMMER DETAILS\\
}