rcc.csc5.code || [Main Index] || [ MATHS ] || [Notation] || [Copyright] || [Contents] || [Source Text] || [Dictionary]
Last updated: Mon Dec 7 10:02:19 PST 2015

Contents (index)


    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


      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: getIntegerNumber.snp

      Example of code in use: getIntegerNumber_example.cpp


    Chapter 6 Algorithm Workbench 37


      My implementation of Chapter 6's Algorithm Workbench 37, with a twist of Chapter 5 Algorithm Workbench #6 can be found here: Chapter6_AW_37.cpp


      Chapter 7 - Arrays

      The following are select programming examples that are found in Chapter 7.

      Program 7-1: ch7_1.cpp

      Program 7-2: ch7_2.cpp

      Program 7-5: ch7_5.cpp

      Program 7-6: ch7_6.cpp

      Program 7-7: ch7_7.cpp

      Program 7-9: ch7_9.cpp

      Program 7-10: ch7_10.cpp

      Parallel Arrays: ch7_parallel_arrays_1.cpp

      Writing out Text File, with text file containing the array content in the format of:

       number_of_elements (n)
       Element_0
       ...
       Element_(n-1)

      The file can be found here: array_write_demo.cpp

      Reading In Text File, Filling Array with textfile content in the format of:

       number_of_elements (n)
       Element_0
       ...
       Element_(n-1)

      The file can be found here: 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):

       Element_0
       ...
       Element_(n-1)

      The file can be found here: 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: vector_read_demo_unknown_list_size.cpp


    Linear Search and Binary Search Demos / Sorting


      The linear and binary search demos done in class and lab.

      Search demo: search_demo.cpp

      The Bubble Sort and Selection Sort code snippets.

      Bubble Sort: bubbleSort.snp

      Selection Sort: selectionSort.snp


    Pointer Examples


      Examples from our 11/23/15 discussion:

      Arrays and Pointers: array_pointers.cpp

      Functions and Pointers: functions_pointers.cpp

      Introduction to #include <cctype> (Chapter 10): cctype_intro.cpp


    Structures2


      Structure Demo 2 source file: structure_demo_2.cpp

      and corresponding .h header file: Money.h


    RCC Courses Page

    Go back to Riverside City College Courses page: rcc.courses.html

    . . . . . . . . . ( end of section CSC 5 - Code Snippets) <<Contents | Index>>


Formulae and Definitions in Alphabetical Order