Create a program
Using Pointers
Create a program that:
- Ask the user for an array size
- Dynamically allocate an integer array with the desired number of elements.
- You’re responsible for cleaning up!
- Ask the user if they would like to:
- input values
- provide a set of rules for randomly generated values to fill the array
- use the default range for random values
- Random values will be generated with the rand function. See end of chapter 8 slides.
- Display the array
- All contents, and the range of memory addresses
- cout << arr;//would display address of int arr[10] or dynamic equivalent
- All contents, and the range of memory addresses
- Sort the array (ascending order) using your method of choice
- 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.
- Display the array
- See 4
- 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..


