Pointers, Dynamic Memory Allocation

  1. Dynamic Integer Array. Study Observing Variables feature of MSVS described here. As you work on the below project, demonstrate to the instructor displaying local variable values with "Autos" and "Locals" tab.

    Create a project titled Lab10_DynamicInt. Write a program that dynamically stores and then prints the array of user-input integers. Your program should ask the user for the number of integers to be entered. Then the program should allocate the appropriate-size array dynamically, store the integers and then print them out. You should use this template for your program. Here is an example dialog of your program:

    Enter number of integers: 5
    Enter integers: -3 -4 6 7 23
    You entered: -3 -4 6 7 23
    

  2. Variable Size Array. Create a project titled Lab10_VarArray. Write a program that allows the user to add or remove an integer number to a collection of integers and then prints all of them them in the increasing order. You can assume that the user never enters the same number twice. First, the user inputs a letter for the operation: (a)dd, (r)emove or (q)uit; then the number.

    Here is an example program dialog:

    enter operation [a/r/q] and number: a 5
    your numbers: 5
    enter operation [a/r/q] and number: a 8
    your numbers: 5 8
    enter operation [a/r/q] and number: r 8
    your numbers: 5
    enter operation [a/r/q] and number: a 3
    your numbers: 3 5
    enter operation [a/r/q] and number: a 12
    your numbers: 3 5 12
    enter operation [a/r/q] and number: q
    

    The size of the user input can be arbitrarily large. For this program, to accommodate user input, you need to implement an integer array whose size varies as necessary. The numbers in the array should not be sorted. You should use the functions prototyped in this header file. The functions there are as follows:

    Hint: Study this example code to see the techniques to use for the above functions.

Make sure your programs adhere to proper programming style. Submit your projects to the subversion repository. Do not forget to verify your submission on the web.