Student Database in C Language
Accept student information (e.g. Roll No, Name, Percentage etc.).
- Display the data in descending order of Percentage (Bubble Sort).
- Display data for Roll No specified by user (Linear Search).
- Display the number of passes and comparisons for different test cases (Worst,
- Average, Best case).
Student Database in C Language Code
#include
#include
#include
#include
class A
{
protected:
char blood[4],name[20];
int date,month,year;
public:
void inputa()
{
cout<<"ENTER NAME";
gets(name);
cout<<"ENTER DATE OF BIRTH";
cin>>date>>month>>year;
cout<<"ENTER BLODD GROUP!!";
gets(blood);
}
virtual void display()
{
cout<<"\nNAME:"<<name; <br=""> cout<<"\nDATE OF BIRTH:"<<date<<" "<<month<<"="" "<<year;="" <br=""> cout<<"\nBLOOD GROUP:"<<blood; <br=""> getch();
}
};
class B:virtual public A
{
protected:
int height;
int weight;
public:
void inputb()
{
cout<<"ENTER HEIGHT";
cin>>height;
cout<<"ENTER weight";
cin>>weight;
}
virtual void display()
{
cout<<"\nheight :"<<height; <br=""> cout<<"\nweight:"<<weight; <br=""> getch();
}
};
class C:virtual public A
{
protected:
int hno ;
char city[10];
unsigned long int insno;
public:
void inputc()
{
cout<<"ENTER ADDRESS OF CARD HOLDER";
cout<<"HOUSE NO";
cin>>hno;
cout<<"CITY";
cin>>city;
cout<<"ENTER INSURANCE NO";
cin>>insno;
}
virtual void display()
{
cout<<"\nADDRESS OF CARD HOLDER:"<<hno<<" "<<city;="" <br=""> cout<<"\nINSURANCE NO OF CARD HOLDER:"<<insno; <br=""> getch();
}
};
class D:public B,public C
{
int licno;
unsigned long int teleno;
public:
int id;
D()
{
id=0;
strcpy(name,'\0');
date=0;
month=0;
year=0;
height=0 ;
weight=0;
strcpy(blood,'\0');
hno=0;
strcpy(city,'\0');
insno=0;
teleno=0;
licno=0;
}
D(D & d)
{
id=d.id;
strcpy(name,d.name);
date=d.date;
month=d.month;
year=d.year;
height=d.height;
weight=d.weight;
strcpy(blood,d.blood);
hno=d.hno;
strcpy(city,d.city);
insno=d.insno;
teleno=d.teleno;
licno=d.licno;
}
void inputd()
{
cout<<"ENTER TELEPHONE NO AFTER FIRST DIGIT ";
cin>>teleno;
cout<<"ENTER LICENCE NO";
cin>>licno;
}
void display()
{
clrscr();
cout<<"\nID NO"<<id; <br=""> cout<<"\nNAME:"<<name; <br=""> cout<<"\nDATE OF BIRTH:"<<date<<" "<<month<<"="" "<<year;="" <br=""> cout<<"\nHEIGHT:"<<height; <br=""> cout<<"\nWEIGHT:"<<weight; <br=""> cout<<"\ncBLOOD GROUP"<<blood; <br=""> cout<<"\nADDRESS:"<<hno<<" "<<city;="" <br=""> cout<<"\nINSURANCE NO:"<<insno; <br=""> cout<<"\nPHONE NO:"<<"9"<<teleno; <br=""> cout<<"\nLICENCE NO:"<<licno; <br=""> getch();
}
};
void main()
{
D d[20];
int ch=0,i=0,j;
do
{
clrscr();
cout<<"\t\t\t\t1.BUILD A MASTER TABLE\n" ;
cout<<"\t\t\t\t2.DISPLAY THE ENTRIES\n" ;
cout<<"\t\t\t\t3.INSERT A NEW DATA\n";
cout<<"\t\t\t\t4.DELETE A DATA\n" ;
cout<<"\t\t\t\t5.SEARCH FOR SPECIFIC ENTRY\n";
cout<<"\t\t\t\t6.EXIT\n" ;
cout<<"\t\t\t\tENTER UR CHOICE";
cin>>ch;
switch(ch)
{
case 1:
cout<<"\n\t\tBUILD A RECORD FOR CREDIT CARD!!";
i=0;
do
{
d[i].id=i+1;
d[i].inputa();
d[i].inputb();
d[i].inputc();
d[i].inputd();
i++;
cout<<"WANT TO ENTER MORE DATA";
}while(getche()=='y');
break;
case 2:
cout<<"\n\t\tDISPLAY CREDIT CARD RECORD!!";
for(j=0;j<i;j++) <br=""> {
d[j].display();
}
break;
case 3:
cout<<"\n\t\tINSERT A NEW RECORD IN CREDIT CARD ENTRY!!";
int k=i;
for(j=0;j<i;j++) <br=""> if(d[j].id!=j+1)
{
k=j;
while(j<i) <br=""> d[j+1]=d[j++];
break;
}
d[k].id=k+1;
d[k].inputa();
d[k].inputb();
d[k].inputc();
d[k].inputd();
i++;
break;
case 4:
cout<<"\n\t\tDELETE A CREDIT CARD RECORD \n\t\tENTER ID";
cin>>k;
for(j=0;j<i;j++) <br=""> if(d[j].id==k)
{
while(j<(i-1))
{
d[j]=d[j+1];
break;
}
}
i--;
break;
case 5:
cout<<"\n\t\tSEARCH FOR SPECIFIC ENTRY\n\t\tENTER ID";
cin>>k;
for(j=0;j<i;j++) <br=""> if(d[j].id==k)
break;
if(j!=i)
{
d[j].display();
}
else
cout<<"SORRY RECORD NOT FOUND";
getch();
break;
case 6:
break;
}
}while(ch!=6);
getch();
}


santosh says
THANK YOU FOR GIVE ME A CODING
THANKS……….
ProjectsGeek says
Thanks
Sushil says
Thank you
DEEPAK says
Thanks you !!
nice all functions working …..