using System;
using System.Linq;
using System.Collections.Generic;
public class Stack
{
int[] ele;
int top;
int max;
public Stack(int size)
ele=new int[size];
top=-1;
max=size;
}
public void push(int val)
if(top == max-1)
Console.WriteLine("overflow");
else
top++;
ele[top]=val;
public int pop()
if(top <0)
Console.WriteLine("underflow"); return -1;
int temp=ele[top];
top--;
return temp;
public void print()
ele.ToList().Where((x,i)=>x!=0 && i<=top).ToList().ForEach(x=>Console.Write(x+" "));
public class Program
public static void Main()
Console.WriteLine("Hello World");
var s=new Stack(4);
s.push(2);
s.push(16);
s.push(3);
s.print();
s.pop();