

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


#include <iostream.h> #include <conio.h> #include <stdio.h> #include <process.h> struct stu { int std_ID; char name[20]; struct stu *next; } first=0,last=0; void main() { clrscr(); int b,key; while (1) { cout << "To enque press 1:"; cout<<"\n To deque press 2:"; cout<<"\nFor display press3"; cout<<"\nTo exit press4:" ; cout<<"\n"; cin >> b; switch (b) { //******insert in end***** case 1: { struct stu *current; current = new stu; current -> next = 0; if ( first== 0 ) { first= current; last = current; } else { last -> next = current; last = current; } cout << "\nStudent ID: "; cin >> current -> std_ID; cout << "\nInput Name: "; gets ( current -> name ); cout<<"\n\n"; break; } //******delete from start case 2:
struct stu *p; p=first; if(first==last) { cout<<"\nque is empty\n"; break; } else { if(first->next==0) { delete(p); } else { p=p->next; first->next=0; delete(first); first=p; } } break; } //****display case 3: { struct stu *p; p = first; while ( p != 0 ) { cout << "\nStudent's ID: " << p -> std_ID << "\nStudent's Name: "; puts ( p -> name ); cout<<"\n\n"; p = p -> next; } break; } //*****exit case 4: { exit(0); break; } } getch(); } }