.Open CSC 5 - Code Snippets . Introduction This page contains any code snippets or source code from our discussions in class or lab that may be of good use. . Code Samples . Useful Code Snippets In the box below, are code snippets that you are free to add to your programs (remember, code re-use is an awesome idea in which we do not spend time "re-inventing" the wheel). . getIntegerNumber .Box Input parameters: minimum and maximum - the minimum and maximum range of integers the user may input. Return: returns the user entered integer in the range of minimum to maximum. Code snippet: .See getIntegerNumber.snp Example of code in use: .See getIntegerNumber_example.cpp .Close.Box . Chapter 6 Algorithm Workbench 37 .Box My implementation of Chapter 6's Algorithm Workbench 37, with a twist of Chapter 5 Algorithm Workbench #6 can be found here: .See Chapter6_AW_37.cpp .Close.Box .Box . Chapter 7 - Arrays The following are select programming examples that are found in Chapter 7. Program 7-1: .See ch7_1.cpp Program 7-2: .See ch7_2.cpp Program 7-5: .See ch7_5.cpp Program 7-6: .See ch7_6.cpp Program 7-7: .See ch7_7.cpp Program 7-9: .See ch7_9.cpp Program 7-10: .See ch7_10.cpp Parallel Arrays: .See ch7_parallel_arrays_1.cpp Writing out Text File, with text file containing the array content in the format of: .As_is number_of_elements (n) .As_is Element_0 .As_is ... .As_is Element_(n-1) The file can be found here: .See array_write_demo.cpp Reading In Text File, Filling Array with textfile content in the format of: .As_is number_of_elements (n) .As_is Element_0 .As_is ... .As_is Element_(n-1) The file can be found here: .See array_read_demo_main.cpp Reading In Text File, Filling Array with text file content in the format of (number of elements in array is unknown - program has to count the number of elements, then re-read in the items): .As_is Element_0 .As_is ... .As_is Element_(n-1) The file can be found here: .See array_read_demo_unknown_array_size.cpp Here is a vector based version of the program named array_read_demo_unknown_array_size.cpp, which does the same logic for the most part except, it does not read in the file twice! It utilizes then vector class member function called push_back, to read in the value from the text file, and place it at the end of the vector as the vector is being built through each iteration. The file can be found here: .See vector_read_demo_unknown_list_size.cpp .Close.Box . Linear Search and Binary Search Demos / Sorting .Box The linear and binary search demos done in class and lab. Search demo: .See search_demo.cpp The Bubble Sort and Selection Sort code snippets. Bubble Sort: .See bubbleSort.snp Selection Sort: .See selectionSort.snp .Close.Box . Pointer Examples .Box Examples from our 11/23/15 discussion: Arrays and Pointers: .See array_pointers.cpp Functions and Pointers: .See functions_pointers.cpp Introduction to #include (Chapter 10): .See cctype_intro.cpp .Close.Box . Structures2 .Box Structure Demo 2 source file: .See structure_demo_2.cpp and corresponding .h header file: .See Money.h .Close.Box . RCC Courses Page Go back to Riverside City College Courses page: .See rcc.courses.html .Close CSC 5 - Code Snippets