C++ Java Python JavaScript Physics Robotics Electronics Astronomy Summer Courses Other Courses

 

Exercises

Exercise 1 - use the stack class

  Create a one-dimensional array with the following integers (left to right): 2 4 8 10 12

  Print the elements of the array, appropriately labeled, all on one line, separated by a space

  Read from the array (left to right) and populate a stack.

  Pop the elements from the stack and print them, appropriately labeled

 

Exercise 2 - use the stack class

Same as exercise 1 except

 

Use a menu system with the following options (to call the functions listed)

Note: do not "hard wire names" - they should be passed to the appropriate function - you can use global names for this exercise

 

1.  CreateArray

      To create the array 

 

2.  PrintArray

     To print the array 

 

3.  CreateStackFromArray

     To read from the array and create the stack

 

4.  PrintStack

     To print the stack