You are on page 1of 3

#include<iostream>

using namespace std;


const int size=10;
class Stack
{
public:
int stack[size],top;
Stack()
{
top=-1;
}

bool Is_empty()
{
bool empty;
return empty=(top==-1)?true:false;
}

bool Is_Full()
{
bool full;
return full=(top==size-1)?true:false;
}
void push(int element)
{
if(!Is_Full())
{
top++;
stack[top]=element;
}
else
{
cout<<"\aStack is full,Can't Insert Element\n";
}
}
void pop()
{
if(!Is_empty())
{
int element=top;
top--;
cout<<"Element ( "<<stack[element]<<" ) Pop Been Done S\n";
}
else
{
cout<<"\aStack is Empty,Cant Pop Element\n";
}
}
int Top()
{
return stack[top];
}

void Stack_Print()
{
if(!Is_empty())
{
cout<<"\aStack Contains Flowing Elements\n";
for (int i =top; i >0 ; i--)
{
cout<<" "<<stack[i]<<"\n";
}
}
}
int element_counter()
{
return top+1;
}
int empty_element_cont()
{
return size-top-1;
}
};

void main()
{
Stack Browser_Histyory;
int element,choice;
Start:
system("cls");
cout<<"1) Push Element.\n2) Pop Element.\n3) Top Of Stack.\n4) Show Stack
Elements.\n5) Exit Program.\n";
cout<<"\n Your Choice:";
cin>>choice;
switch (choice)
{
case 1:
goto Push;
break;
case 2:
goto Pop;
break;
case 3:
goto Stack_top;
break;
case 4:
goto Stack_print;
break;
case 5:
goto Exit;
break;
default:
cout<<"\aWronggggg Choice\n";
goto Start;
break;
}
Push:
cout<<"Element You Want To Push:";
cin>>element;
Browser_Histyory.push(element);
Pop:
Browser_Histyory.pop();
Stack_top:
cout<<"\aTop Elememt Of Stack Is ( "<<Browser_Histyory.Top()<<" )\n";
Stack_print:
Browser_Histyory.Stack_Print();
Exit:
system("pause");
}

You might also like