Create a program

Create a program

Using Pointers

Create a program that:

  1. Ask the user for an array size
  2. Dynamically allocate an integer array with the desired number of elements.
    1. You’re responsible for cleaning up!
  3. Ask the user if they would like to:
    1. input values
    2. provide a set of rules for randomly generated values to fill the array
    3. use the default range for random values
      1. Random values will be generated with the rand function. See end of chapter 8 slides.
  4. Display the array
    1. All contents, and the range of memory addresses
      1. cout << arr;//would display address of int arr[10] or dynamic equivalent
  5. Sort the array (ascending order) using your method of choice
    1. Extra credit: Include BOGOsort (aka dumb sort), where the array is shuffled randomly then checked for order. If BOGOsort is chosen, the user should be told how many shuffles the solution took.
  6. Display the array
    1. See 4
  7. Ask the user if they wish to return to step 1. The array should be recreated if they return to step 1.

Define and make use of these functions:

void swap(int * a, int * b);//Switches the contents in a and b

//Will fill all entries in the array with a number between min and (min + range)

void fillRandom(int * arr, int numEntries, int range = 100, int min = 0)

/*userSelection, bubbleSort, and selectSort would all have fillRandom’s argument list without range or min.*/

If you’re unfamiliar with pointers, look to the slides and/or try working on this assignment with a regular array first

Also valid:

void fillRandom(int [] arr, … )

Points:

1 – Documentation, readability, format

3 – Proper use of pointers

2 – Proper program flow (conditionals, loops, etc)

2 – Filename and Header

2 – Output testing

Header

//Author: Eric May (your name)

//CPSC 121 Lab 6

//<MM/DD/YY> (Current Date)

Filename

<Last Name><First Initial>lab7.cpp

For example, my assignment would be named MayElab6.cpp

"You need a similar assignment done from scratch? Our qualified writers will help you with a guaranteed AI-free & plagiarism-free A+ quality paper, Confidentiality, Timely delivery & Livechat/phone Support.


Discount Code: CIPD30



Click ORDER NOW..

order custom paper