/* This program uses a 2D array and implements it as a stack */ #include int push(char [][15],int); int pop(int); void display(char [][15],int); void main() { char names[][15]={"Alpesh ","Alps ","Rick "}; int count=3; puts("The original stack is as follows:"); display(names,count); puts("After popping the top name, the stack is as follows:"); display(names,pop(count)); push(names,count); puts("After pushing on a name, the stack is as follows:"); display(names,count); } int pop(int count) { return --count; } void display(char n[][15],int count) { int i; for(i=(count-1);i>=0;--i) printf("%s\n",(n+i)); puts(""); } int push(char n[][15],int count) { puts("Enter a name:"); gets(n[count-1]); puts(""); return count++; }