



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
code for graphs in dsa.....FOR ALL STUDENTS WHO ARE BEGINNERS AND WANT TO LEARN CODING
Typology: Lab Reports
1 / 5
This page cannot be seen from the preview
Don't miss anything!




#include
top = temp; cout << "Last Operation: Data PUSHED in Stack"<< endl<< endl; } void pop() { clearScreen(); node temp; temp=top; if(top==NULL) { cout<<"Stack UnderFlow"<<endl<<endl; }else { cout << "Last Operation: Data POP from Stack: " << top -> data<< endl<< endl; top = top->next; } delete temp; } void display() { cout << "top -> "; node curr = top; while (curr != NULL) { cout << curr -> data << " -> ";
void clearScreen() { system("CLS"); cout << "******** STACK ********" << endl << endl; } }; int main() { Stack st; system("CLS"); cout << "******** STACK ********" << endl << endl; int choice = -1; while (choice != 0) { st.display(); cout << endl << endl; cout << "Press 1 : Push data to STACK" << endl; cout << "Press 2 : Pop data from STACK" << endl; cout << "Press 3 : Display data of STACK" << endl; cout << "Press 0 : Exit" << endl; choice = -1; while (choice < 0 || choice > 3) { cout << "\nEnter your choice here: "; cin >> choice; cout << endl; }
int data; switch (choice) { case 1: cout << "Enter Data: "; cin >> data; st.push(data); break; case 2: st.pop(); break; case 3: st.displayInDetail(); break; default: break; } } }