0% found this document useful (0 votes)
7 views10 pages

Topic:: Saving Teachers Information

Uploaded by

amnasaleem579
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views10 pages

Topic:: Saving Teachers Information

Uploaded by

amnasaleem579
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Topic:

Saving Teachers Information

Project Code:

#include<iostream>

#include<conio.h>

#include<string.h>

using namespace std;

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<<" >>>>>>>>>>>>> TEACHERS INFORMATION <<<<<<<<<<< "<<endl;

cout<<" ''''''''''''''''''''''''''''''''''''''''''''''' "<<endl;

cout<<" =============================================== "<<endl;

cout<<endl;

cout<<"Enter id "<<endl;

int id;

cin>>id;

cout<<"Enter name "<<endl;


string Name;

cin>>Name;

cout<<"Enter phone number"<<endl;

cin>>phone_no;

cout<<"enter CNIC"<<endl;

double cnic;

cin>>cnic;

cout<<"enter Age"<<endl;

double Age;

cin>>Age;

TeachersInfo *tmp=new TeachersInfo;

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;

cout<<"Enter name to search:"<<endl;

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<<"| ID | Name | phone number | CNIC | Age |";

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:

You might also like