STACC ATACC 2.0
STACC ATACC 2.0
void push(int x)
{
if (top >= n - 1)
{
cout << "STACK OVERFLOW" << endl;
}
else
{
top++;
arr[top] = x;
}
void pop()
{
if (top <= -1)
{
cout << "STACK UNDERFLOW" << endl;
}
else
{
top--;
cout << arr[top] << endl;
}
void print()
{
if (top >= 0)
{
}
}
else
{
cout << "STACK IS EMPTY" << endl;
int main()
{
char A;
int B, C;
int a = 0;
while (a < 2) {
cout << "IF YOU WANT TO PUSH ELEMENTS INTO THE STACK THEN SELECT
'A':" << endl;
cout << "IF YOU WANT TO Pop ELEMENTS out of THE STACK THEN SELECT
'B':" << endl;
cin >> A;
switch (A)
{
case 'A':
cout << "how many times do you want to insert elements into
the stack?(max 10)" << endl;
cin >> B;
while (B > 0)
{
cout << "enter the elements:" << endl;
cin >> C;
push(C);
B--;
}
break;
case 'B':
cout << "how many times do you want to pop elements out of
the stack?(max 10)" << endl;
cin >> B;
cout << "the following elements are poped out:" << endl;
while (B > 0)
{
pop();
B--;
}
break;
}
a++;
}
print();
return 0;
}