Description
Implement a small program (lab2.cpp) that defines a regular number type variable, and
a pointer variable to the same type of number. Only two or three variables are needed – do not
declare more than that. Use these variables for the following tasks (be sure to label each of
these tasks, using comments):
1) ask the user for a value and store it in the regular variable
2) make the pointer variable point to the regular variable location
3) use both the regular variable and pointer variable to print the VALUE stored and
the ADDRESS the value is stored at (four things should be printed, some will be the same)
4) use the pointer variable to allocate memory for a single value
5) store a value (any value you choose) into this newly allocated memory
6) print the same items as in step 3 (perhaps a function would help?)
7) deallocate the memory allocated in step 5
8) ask the user for a small number and use the pointer variable to allocate memory for
an array of that size of the appropriate number type
9) store random values in all elements of this newly allocated array (use array notation)
10) print all elements of the array (use array notation)
11) deallocate any allocated memory and end the program
Submit your program by typing the following command at the prompt in the same directory
where the file is stored:
/home/fac/sreeder/submit/cpsc2430/lab2_runme