From bcee12e3c61089ecba9036e827b545e0e4f04586 Mon Sep 17 00:00:00 2001 From: anubis-x-ranger <44902527+anubis-x-ranger@users.noreply.github.com> Date: Tue, 22 Oct 2019 21:00:55 +0530 Subject: [PATCH] Stack using Array --- .../Stack and Queue /stackarray.cpp | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 Data Structures/Stack and Queue /stackarray.cpp diff --git a/Data Structures/Stack and Queue /stackarray.cpp b/Data Structures/Stack and Queue /stackarray.cpp new file mode 100644 index 0000000..374a265 --- /dev/null +++ b/Data Structures/Stack and Queue /stackarray.cpp @@ -0,0 +1,80 @@ +#include +#include +#include +class stack +{ + int stk[5]; + int top; + public: + stack() + { + top=-1; + } + void push(int x) + { + if(top > 4) + { + cout<<"Stack OverFlow."; + return; + } + stk[++top]=x; + cout <<"Inserted element is: " <=0;i--) + cout <>ch; + switch(ch) + { + case 1: cout <<"\nEnter the element to be added: "<>ch; + st.push(ch); + break; + case 2: st.pop(); + break; + case 3: st.topp(); + break; + case 4: st.display(); + break; + case 5: exit(0); + } + } + getch(); +}