Console.WriteLine("Stack Overflow");
Console.Write("Enter a number : ");
arr[top] = Convert.ToInt32(Console.ReadLine());
Console.Write("Stack after adding the current number is : ");
for (int i = 0; i <= top; i++)
Console.Write(arr[i] + ",");
Console.WriteLine("Stack underflow");
Console.WriteLine("Element removed is : " + arr[top]);
Console.WriteLine("No element to display");
Console.Write("Stack is : ");
for (int i = 0; i <= top; i++)
Console.Write(arr[i] + ",");
public static void Main()
MyStack S = new MyStack();
Console.WriteLine("Menu:\n 1) Add an element to stack\n 2) Remove an element from stack\n 3) Print stack\n 4) Exit");
int option = Convert.ToInt32(Console.ReadLine());
System.Environment.Exit(0);
Console.WriteLine("Wrong chice. Do you want to continue ?");
conty = Convert.ToChar(Console.ReadLine());
while (conty == 'Y' || conty == 'y');