Upload
ch-nawaz
View
112
Download
2
Tags:
Embed Size (px)
DESCRIPTION
Student Data Base Using C/C++ Final Project
Citation preview
Comsats Institute Of Information And Technology Islamabad Chak Shahzad
Haq Nawaz CH
Sp12-BCS-089
Student Data Base program C/C++
Output :
C/C++ CODE
#include<iostream>#include<conio.h>#include<cstring>#include<ctype.h>#include<stdlib.h>#include<stdio.h>using namespace std;void show1();void pass();void menu();void entrec();void modpass();void modrec();void mdf();void show();void upd_rec();void srch();void exit();void hid();void del();int t=0;
struct name { char first_name[20]; char last_name[20]; };
struct pass { char name[20]; char pass[20]; }user;
struct bio_data {
name ful_name;char add[100];int age;int phon_num;char gender[10];
};
bio_data p[10];
int i=0; int main() { char hid[11];for (int t=0;t<10;t++)
hid[t]=0;strcpy(user.name,"ABC");strcpy(user.pass,"ABC");
pass();getch();
}
void pass() //defination of password { system("cls"); char name[20]; char password[20]; cout<<"Enter user name"<<"\t:"; cin>>name; cout<<"Enter password"<<"\t:"; cin>>password; int c,c1; int i=0;
char pw;
c=strcmp(name,user.name); c1=strcmp(password,user.pass); if(c==0&&c1==0) { system("cls"); cout<<"welcome menue"<<endl; menu(); getch(); } else
if(c!=0||c1!=0) { system("cls");
cout<<"login not match try again";}
getch(); pass();
// cout<<"modify passw"; }
void menu(){ system("cls"); cout<<"\t\t\t______________________________"<<endl;
cout<<"\t\t\t\twelcome to Menu"<<endl;cout<<"\t\t\t\t1:Enter Record"<<endl;cout<<"\t\t\t\t2:Show Record"<<endl;cout<<"\t\t\t\t3:Modify Record"<<endl;cout<<"\t\t\t\t4:Hide Record"<<endl;cout<<"\t\t\t\t5:Delete Record"<<endl;cout<<"\t\t\t\t6:Modify Password"<<endl;cout<<"\t\t\t\t7:Search Record"<<endl;cout<<"\t\t\t\t8:Exit Menu"<<endl;cout<<"\t\t\t______________________________"<<endl; int choice; cout<<"Enter your choice:\t"; cin>>choice; switch(choice) {
case 1: entrec();
break;
case 2: show();
break;case 3:
mdf();break;
case 4: hid();
break; case 5:
del(); break;case 6:
modpass();break;
case 7: srch();
break;case 8:
exit();
break;
}menu();}
void modpass(){ system("cls");
cout<<"\t\tEnter new password"<<endl;char pw;int i=0;cin>>user.pass;system("cls");cout<<"\t\tPassword Cahnged"<<endl;cout<<"\t\tPress Enter to Continue"<<endl;pass();getch();
}
void entrec() { system("cls"); cout<<"enter number of record you want to add"<<endl; int n; cin>>n;
for(int i=1;i<=n;i++){
cout<<"_______________"<<endl;cout<<"enter 1st name :\t";cin>>p[i].ful_name.first_name;cout<<"enter last name:\t";cin>>p[i].ful_name.last_name;cout<<"address :\t";cin>>p[i].add;cout<<"age :\t";cin>>p[i].age;cout<<"phon :\t";cin>>p[i].phon_num;cout<<"gender :\t";cin>>p[i].gender;
getch();}
}
void del() { system("cls");
cout<<"enter required out put number\t"<<endl;int n,a;cin>>n;a=0;char lname[20];cout<<"enter last name to del record"<<endl;cin>>lname;for(int i=1;i<=n;i++){
if(strcmp(p[i].ful_name.last_name,lname)==0){
cout<<"\t----------------------------------"<<endl; cout<<"\tfirst name:\t"<<p[i].ful_name.first_name=='\0'; cout<<"\tlast name :\t"<<(p[i].ful_name.last_name)=='\0'; cout<<"\taddress :\t"<<p[i].add=='\0'; cout<<"\tphone# :\t"<<p[i].phon_num=='\0'; cout<<"\tage :\t"<<p[i].age=='\0'; cout<<"\tgender :\t"<<p[i].gender=='\0'; cout<<"\t----------------------------------"<<endl; }a++; cout<<"showing records:"<<a<<endl; getch();}}
void mdf(){
system("cls");int n;
char lname[20];cout<<"enter last name"<<endl;cin>>lname;
//cout<<"search upto ....num?"<<endl;//cin>>n;
for(int i=1;i<=9;i++) {
if(strcmp(p[i].ful_name.last_name,lname)==0){
cout<<"enter 1st name:\t";cin>>p[i].ful_name.first_name;cout<<"enter last name:\t";
cin>>p[i].ful_name.last_name;cout<<"address:\t";cin>>p[i].add;cout<<"age:\t";cin>>p[i].age;cout<<"phon:\t";cin>>p[i].phon_num;cout<<"gender:\t";cin>>p[i].gender;
}//getch(); } getch(); menu();
}
void show1() { system("cls");
for(int i=1;i<=5;i++){
cout<<"\t----------------------------------"<<endl; cout<<"\tfirst name:\t\t"<<p[i].ful_name.first_name<<endl; cout<<"\tlast name :\t\t"<<p[i].ful_name.first_name<<endl; cout<<"\taddress :\t\t"<<p[i].add<<endl; cout<<"\tage :\t\t"<<p[i].phon_num<<endl; cout<<"\tgendr :\t\t"<<p[i].age<<endl; cout<<"\tphon num :\t\t"<<p[i].gender<<endl; cout<<"\t----------------------------------"<<endl; } //break; getch();}
void exit(){
exit(0);}
void hid(){ char hide[t];
for (int t=0;t<10;t++)hide[t]=0;
char nme[20];char h;h=0;cout<<"Please Enter last name to hide:";cin>>nme;
for (int i=0;i<9;i++){
if (strcmp(p[i].ful_name.last_name,nme)==0){
hide[i]=1;}
h=1;}
cout<<"Hidden Successful"<<endl;if (h==0) cout<<"Record not Available"<<endl; getch();
menu();}
void srch(){ system("cls"); char hide[10];for (int t=0;t<10;t++)
hide[t]=0;char nm[20];char a;a=0;
cout<<"\nEnter Patient Last Name:";cin>>nm;for (int i=0;i<9;i++){
if (strcmp(p[i].ful_name.last_name,nm)==0 && hide[i]==0){
cout<<"\t\t------------------------"; cout<<"\n\t\t1 Record match!!!\n"; cout<<"\n\t\tFirst Name :";
cout<<p[i].ful_name.first_name;cout<<"\n\t\tPatient Last Name :";cout<<p[i].ful_name.last_name;cout<<"\n\t\tPatient Phone number:";cout<<p[i].phon_num;cout<<"\n\t\tPatient Age :";
cout<<p[i].age;cout<<"\n\t\tPatient gender :";cout<<p[i].gender<<endl;cout<<"\t\t------------------------\n";cout<<"\n\n\n";a=1;
}
}
if (a==0) cout<<"\nRecord not available\n";
getch();menu();}
void show(){ system("cls"); char hide[10];for (int t=0;t<10;t++)
hide[t]=0;for (int i=0;i<9;i++){
if (hide[i]==0&& strlen(p[i].ful_name.last_name)>0){ cout<<"\nRecord number \t :"<<i+1; cout<<"\nPatient First Name\t :";
cout<<p[i].ful_name.first_name;cout<<"\nPatient Last Name\t :";cout<<p[i].ful_name.last_name;cout<<"\nPatient Phone number\t:";cout<<p[i].phon_num;cout<<"\nPatient Address \t:";cout<<p[i].add;cout<<"\nPatient Age \t:";cout<<p[i].age;cout<<"\nPatient gender \t:";cout<<p[i].gender;cout<<endl;
}}getch();
}
/*void del() { system("cls");
char name[22];cout<<"enter 1st name to dell"<<endl;cin>>name;int a,b;for(int i=0;i<=9;i++){
a=strcmp(name,p[i].ful_name.first_name);if(a==0){
cout<<p[i].ful_name.first_name=='\0';cout<<p[i].ful_name.last_name=='\0';cout<<p[i].add=='\0';cout<<p[i].phon_num=='\0';cout<<p[i].age=='\0';
cout<<p[i].gender=='\0';
}
}cout<<"record deleted"<<endl;getch();
}*/