244: VSSORT

In C++, create an array and fill with random numbers, sort, search and print.

0. Come to class as there may be corrections, changes and additions.   Significant late penalty.
1. Using Visual C++ Express, create a  C++  console project called VSSORT. ( directions to create a C++ console program )
2. Follow these directions to SUBMIT a folder called "VSSORT" to your class account
3. Comment! (guidelines)
4. Review the HONESTY policy. Document sources both inanimate and animate!.


Graded According to Accuracy and Attention to Detail

Create a C++ console program in Visual Studio with 7 functions (main, menu, getint, random, bubble, search, print) in SEVEN files: main.cpp, menu.cpp getint.cpp random.cpp, print.cpp, bubble.cpp, search.cpp.
Display a menu via a function, menu() and use getint() to get the menu selection. getint() gets user input and checks numbers for validity and range menu() simply displays the menu From main, loop and display the menu as follows until exit. Upon user selection, call appropriate functions passing any needed information as a parameter. 1. In main(), call getint() to prompt the user for size of an array, and create an array of ints (1-100). Enter an array size. Enter an integer between 1 and 100: doggy Enter an integer between 1 and 100: 0 Enter an integer between 1 and 100: 10 2. Call random() that will fill the passed array with random numbers from 0-99. 3. Call bubble() that will sort the passed array using the infamous bubble sort. 4. Call print() that will print all items of the passed array. Print the array index, the hex address and the decimal contents 0 01054848:: 3 1 0105484C:: 12 2 01054850:: 14 3 01054854:: 35 5. Call getint() to get the value to be found and then call search() to determine how often that value you pass appears in the passed array. Enter a value to search for. Enter an integer between 0 and 99: doggy Enter an integer between 0 and 99: 10000 Enter an integer between 0 and 99: 12 Found value 12 1 time(s). 0. Exit. In main(), simply return 0;

Menu choices may be selected in ANY order should NOT ABORT!!


EXAMPLE : 1.create array 2.randomize 3.bubble sort 4.print array 5.search 0.exit choice: Enter an integer between 0 and 5: 1 Enter an array size. Enter an integer between 1 and 100: 110 Enter an integer between 1 and 100: 11 1.create array 2.randomize 3.bubble sort 4.print array 5.search 0.exit choice: Enter an integer between 0 and 5: 2 1.create array 2.randomize 3.bubble sort 4.print array 5.search 0.exit choice: Enter an integer between 0 and 5: 3 1.create array 2.randomize 3.bubble sort 4.print array 5.search 0.exit choice: Enter an integer between 0 and 5: 4 0 01054848:: 3 1 0105484C:: 12 2 01054850:: 14 3 01054854:: 35 4 01054858:: 39 5 0105485C:: 48 6 01054860:: 69 7 01054864:: 76 8 01054868:: 82 9 0105486C:: 86 10 01054870:: 87 1.create array 2.randomize 3.bubble sort 4.print array 5.search 0.exit choice: Enter an integer between 0 and 5: 5 Enter a value to search for. Enter an integer between 0 and 99: doggy Enter an integer between 0 and 99: 1000 Enter an integer between 0 and 99: 12 Found value 12 1 time(s).

Bubble Sort! (wikipedia)

XOR SWAP (wikipedia)