Program+12

Hey ... look at the STACK!  Since most of us have finished the Bubble Sort, so we are going to learn about a STACK. A STACK is a "Data Structure" that will serve as a type of Queue. While most Queues are First In First Out (FIFO), A Stack is Last In First Out (LIFO) Queue. Think of a Stack of Plates at an all you can eat food bar ... The last plate on the stack is the first plate off.

Watch the first section on stacks and then do the following project.

media type="custom" key="10712448"

After you get the gist about stacks, then do the following:

Create an array with 100 cells to store your data. This will be your STACK. Create a POINTER (a variable) that holds the slot number of the last item PUSHED on the stack. The POINTER will be set to ZERO at first, because the STACK is empty.

You will need to use a WHILE LOOP (Yes this is a new loop and set if for PRE rather than POST testing). In the loop you will ask the user to enter a number (a command) that has the following meaning: 0 -- Stop the loop and go home, I'm tired. 1 -- PUSH something on the stack. (INCREMENT the POINTER, INPUT something, and PUSH it on the STACK). 2 -- POP something off of the stack (Display what was popped and DECREMENT the POINTER).

Note -- when you POP the STACK and the POINTER is ZERO, Tell the user that the STACK is EMPTY.

HAVE a NICE DAY :)