Implementation of Stack Using Linked List
Implementation of Stack Using Linked List
//DRIVER PROGRAM
using namespace std;
#include<iostream>
//#include "StackADT.h"
#include "StackList.h"
int main(){
int ch;
char c;
StackList <char> myStack;
while(true){
cout<<"----MENU----";
cout<<"\n1.Push\n2.Pop\n3.Peek\n4.Display\n";
cin>>ch;
switch(ch){
case 1: char x;
cout<<"Enter data "<<endl;
cin>>x;
myStack.push(x);
break;
case 2: myStack.pop();
break;
case 3: c = myStack.peek();
if(c==0)
cout<<"Stack is empty"<<endl;
else
cout<<"The top element is:"<<myStack.peek()<<endl;
break;
case 4: cout<<"The Stack is\n";
myStack.display();
break;
default: return 0;
}
}
return 0;
}