import java.util.*;
import java.lang.*;
import java.io.*;
static final int capacity = 5;
int top;
int a[] = new int[capacity]; // Maximum size of Stack
boolean isEmpty()
{
return (top < 0);
}
{
top = -1;
}
boolean push(int x)
{
if (top >= (capacity - 1)) {
system.
out.
println("Stack is full");
return false;
}
else {
a[++top] = x;
system.
out.
println(x +
" pushed into stack");
return true;
}
}
int pop()
{
if (top < 0) {
system.
out.
println("Stack empty");
return 0;
}
else {
int x = a[top--];
return x;
}
}
int peek()
{
if (top < 0) {
system.
out.
println("Stack empty");
return 0;
}
else {
int x = a[top];
return x;
}
}
void print_stack(){
for(int i = top;i>-1;i--){
system.
out.
print(" | "+ a
[i
]);
}
}
}