Topic:: Saving Teachers Information
Topic:: Saving Teachers Information
Project Code:
#include<iostream>
#include<conio.h>
#include<string.h>
string data;
struct TeachersInfo
int id;
string Name;
int phone_no;
int cnic;
int Age;
TeachersInfo *next;
};
class Info{
private:
TeachersInfo *head,*tail;
public:
Info()
head=tail=NULL;
void InsertData()
cout<<endl;
cout<<endl;
cout<<endl;
cout<<"Enter id "<<endl;
int id;
cin>>id;
cin>>Name;
cin>>phone_no;
cout<<"enter CNIC"<<endl;
double cnic;
cin>>cnic;
cout<<"enter Age"<<endl;
double Age;
cin>>Age;
tmp->Name=Name;
tmp->phone_no=phone_no;
tmp->cnic=cnic;
tmp->Age=Age;
tmp->next=NULL;
if(head==NULL)
head=tail=tmp;
else
tail->next=tmp;
tail=tail->next;
}}
void searchInfo()
TeachersInfo *prev=NULL;
TeachersInfo *current=NULL;
string Name;
cin>>Name;
prev=head;
current=head;
while(current->Name!=Name)
prev=current;
current=current->next;
}
cout<<"\nID: ";
cout<<current->id;
cout<<"\nName:";
cout<<current->Name;
cout<<"\nPhone No:";
cout<<current->phone_no;
cout<<"\nCNIC:";
cout<<current->cnic;
cout<<"\nAge:";
cout<<current->Age;
getch();
void Display(){
cout<<"=======================================================================
============";
cout<<"\n";
cout<<"\n";
cout<<"=======================================================================
============";
TeachersInfo *temp;
temp = tail;
while(temp != NULL){
cout<<"\n";
cout<<"|\t"<<temp->id<<"\t|\t"<<temp->Name<<"\t|\t"<<temp-
>phone_no<<"\t|\t"<<temp->cnic<<"\t|\t"<<temp->Age<<endl;
cout<<"\n";
cout<<"=======================================================================
======\n";
temp = temp->next ;
cout<<endl;
}}
};
int main()
Info b;
int n;
do{
cout<<"Press 1 to Insert\nPress 2 to Display Information \nPress 3 to search\n press 4 to Exit
"<<endl;
cin>>n;
if(n==1)
b.InsertData();
else if(n==2)
b.Display();
else if(n==3)
b.searchInfo();
else if(n==4)
exit(0);
else
{
}
while(n!=4);
Output: