Hello. Can someone please write a C program that has the following characteristics:
1) Uses a LIFO stack to store integers
2) User can enter values(PUSH)
3) User can remove values(POP)
4) Stack is printed to the screen when the program starts and each time PUSH or POP is performed.
5) The top of the stack contains the newest element, the bottom contains the oldest element.
I want the program to actually print out something that looks like a stack. Something like this:
Note: The output of my program is nicely aligned to make a rectangle.Code:#include <stdio.h>
#include <stdlib.h>
int main()
{
int stackElement=9;
int i;
for(i=0; i<10; i++)
{
printf("+------------+\n");
printf("| %d |\n",stackElement);
printf("| |\n");
printf("+------------+\n");
stackElement--;
}
return 0;
}
This isn't homework. I want to learn stacks on my own and I think a program like this would help me. Please use as few functions and pointers as possible.