Posts

Showing posts from November, 2020

Implementation of Double link list in c++

Implementation of Double link list in c++  #include<iostream> using namespace std; struct Node { int data; Node* next; Node* prev; }; Node* first = NULL; Node* last = NULL; void insertAtLast(int val) { Node* new_node = new Node; new_node->data = val; if (last == NULL) { new_node->next = new_node->prev = NULL; first = last = new_node; } else { new_node->next = NULL; new_node->prev = last; last->next = new_node; last = new_node; } } void insertAtFirst(int val) { Node* new_node = new Node; new_node->data = val; if (first == NULL) { new_node->next = new_node->prev = NULL; first = last = new_node; } else { new_node->prev = NULL; new_node->next = first; first->prev = new_node; first = new_node; } } void traverseFirst() { Node* new_node = new Node; new_node = first; while (new_node != NULL) { cout << new_node->data << "

Airline Management System with Double link list in c++

Airline Management System with Double link list in c++ #include<iostream> #include<string> #include<ctype.h> #include<cstring> using namespace std; struct Person{ string name; int age; string cnic; int TicketNo; string FlightNo; }; struct Cust{ Person obj; Cust *next; Cust *pre; }; Cust *firstC = NULL; Cust *lastC = NULL; struct Flight{ Cust *head; Flight *next; Flight *pre; string name; void ReserveFromF() { system("cls"); Cust *newNode = new Cust; cout << "Enter the name of the customer:"; getline(cin, newNode->obj.name); cout << "Enter the CNIC number:"; getline(cin, newNode->obj.cnic); cout << "Enter the flight number:"; getline(cin, newNode->obj.FlightNo); cout << "Enter the Age of the customer(int):"; cin >> newNode->obj.age; cout << "Enter the Ticket Number(int):"; cin >

Implementation of single link list c++

 Implementation of single link list c++ #include<iostream> using namespace std; struct Node{ int value; Node *next; }; Node *head=NULL; void insert(int a) { Node *temp = new Node; temp->value = a; if (head == NULL) { temp->next = NULL; head = temp; cout << "Value was null" << endl; } else { temp->next = head; head = temp; cout << "Value is not null" << endl; } } void display() { Node *temp = new Node; temp = head; while (temp != NULL) { cout << temp->value << endl; temp = temp->next; } } int main() { insert(5); insert(6); insert(7); display(); getchar(); return 0; }

Stack using single link list in c++

 Stack using single link list in c++ #include<iostream> using namespace std; class Pile{ public: int plate; Pile *next; Pile *top = NULL; void push(int val) { Pile *temp = new Pile; temp->plate = val; temp->next = top; top = temp; } int pop() { if (isEmpty()) { cout << "There is no plate" << endl; return 0; } else { Pile *temp = top; top = top->next; delete(temp); return top->plate; } } bool isEmpty() { return (top == NULL); } int peek() { if (isEmpty()) { cout << "There is no plate" << endl; return 0; } else { return top->plate; } } }; int main() { Pile blue; blue.push(5); blue.push(55); blue.push(11); blue.pop(); blue.pop(); cout << "Value is:" << blue.peek() << endl; getchar(); getchar(); return 0; }

Implementation of Stack using Arrays c++

 Implementation of Stack using Arrays c++ #include<iostream> using namespace std; #define Max 10 class Stack{ int top = -1; public: int stack[Max]; bool push(int val) { if (isFull()) { cout << "Stack is full" << endl; return false; } else { stack[++top] = val; return true; } } int pop() { if (isEmpty()) { cout << "Stack is empty" << endl; return 0; } else { int a = stack[top--]; return a; } } bool isFull() { return (top > Max - 1); } bool isEmpty() { return (top < 0); } int peek() { if (isEmpty()) { cout << "Stack is empty" << endl; } else { int a = stack[top]; return a; } } }; int main() { Stack s1; s1.push(5); s1.push(2); cout<<s1.pop(); getchar(); getchar(); return 0; }

Ticket Management System using link list

Ticket Management System using link list   #include<iostream> #include<string> #include<cstring> #include<ctype.h> using namespace std; class Ticket { public: int ticketNo, seatNo, AirNo; string cnic, ticketDate; string FName; Ticket *next; Ticket() { FName= '\0'; cnic = ticketDate = " "; ticketNo = seatNo = AirNo = 0; } }; Ticket *head = NULL; int position=0; class Airline{ public: void ResTicket() { system("cls"); Ticket *Node = new Ticket; cout << "Enter the ticket number(integer):"; cin >> Node->ticketNo; cout << "Enter the Airline number(integer):"; cin >> Node->AirNo; cout << "Enter the seat number(integer):"; cin >> Node->seatNo; cin.ignore(); cout << "Enter the Name:"; getline(cin, Node->FName); cout << "Enter the CNIC:"; getline(cin, Node->cnic); cout &

Library Management System using Single Link list

 Library Management System using Link list #include<iostream> #include<string> using namespace std; class Books{ public: int ISBN; string Name, AName, PName, IDate, RDate; Books *next; Books() { ISBN = 0; Name, AName, PName, IDate, RDate = " "; } }; class Library{ public: Books *head = NULL; int size; void CreateBook() { cout << "How many books do you want to enter:"; cin >> size; cin.ignore(); for (int i = 0; i < size; i++) { cout << endl << endl; Books *tempBook = new Books; cout << "Enter the isbn number of book(in int):"; cin >> tempBook->ISBN; cin.ignore(); cout << "Enter the name of the book:"; getline(cin, tempBook->Name); cout << "Enter the auther name of the book:"; getline(cin, tempBook->AName); cout << "Enter the publisher name of the author:"; getline(cin, tempBook->PN

Employee and Customer Management System using single link list

Customer and Employee Management System using link list  #include<iostream> #include<string> using namespace std; class Customer{ public: int custCnic; string custName, custAdress,custPhone,custType; Customer *custNext; Customer() { custCnic = 0; custName = custAdress = custPhone = custType = " "; } Customer(int cnic, string name, string adress, string phone, string type) { custCnic = cnic; custName = name; custAdress = adress; custPhone = phone; custType = type; } }; class Employee{ public: int empCnic; string empName, empAdress, empPhone, empType; Employee *empNext; Employee() { empCnic = 0; empName = empAdress = empPhone = empType = " "; } Employee(int cnic, string name, string adress, string phone, string type) { empCnic = cnic; empName = name; empAdress = adress; empPhone = phone; empType = type; } }; class DSA{ public: Customer *custHead = NULL; Employee *empHead = NULL; void insertCust() { Customer *temp

Library Management System

Library Management System   #include<iostream> #include<string> using namespace std; class Library{ int books; string name, author, publisher, issueDate, returnDate; int isbnNo; public: void create() { cout << "Enter the name of the book:"; getline(cin, name); cout << "Enter the author name:"; getline(cin, author); cout << "Enter the ISBN number(in integer):"; cin >> isbnNo; cin.ignore(); cout << "Enter the publisher name:"; getline(cin, publisher); cout << "Enter the issue date:"; getline(cin, issueDate); cout << "Enter the return date:"; getline(cin, returnDate); } void retrieve(Library *l, int size, int a) { int count = 0; for (int i = 0; i < size; i++) { if (l[i].isbnNo == a) { l[i].author = " "; l[i].books = l[i].books - 1; l[i].isbnNo = 0; l[i].issueDate = " "; l

Employee and Customer Management System C++

Image
Management System(Employee and Customer)   #include<iostream> #include<string> using namespace std; class Customer{ public: string custName, custAdress, custType,custPhone; int custCnic; Customer(){ custName = custAdress = custType=custPhone = "0"; custCnic = 0; } Customer(string a, string b, string c,string d, int e) { custName = a; custAdress = b; custType = c; custPhone = d; custCnic = e; } }; class Employee{ public: string empName, empAdress, empType,empPhone; int empCnic; Employee(){ empName = empAdress = empType,empPhone = "0"; empCnic = 0; } Employee(string a, string b, string c,string d, int e) { empName = a; empAdress = b; empType = c; empPhone = d; empCnic = e; } }; class DSA{ public: void Create(Employee *e, int size) { for (int i = 0; i < size; i++){ cout << endl; cout << "Please enter the cnic number for Employee(in integer):";