[Skip Navigation] [CSUSB] / [CNS] / [Comp Sci & Eng Dept] / [R J Botting] >> [CSci201] >> [Lab01] >> index
[Index] [Schedule] [Syllabi] [Glossary] [Labs] [Projects] [Resources] [Grading] [Search ]
Notes: [01] [02] [03] [04] [05] [06] [07] [08] [09] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20]
Labs: [01] [02] [03] [04] [05] [06] [07] [08] [09] [10]
Tue Feb 9 13:53:06 PST 2010


    CSCI201/lab06 functions

      Previous [ ../lab05/ ] Next [ ../lab07/ ]


      Complete two programming exercises with functions using unit testing. All the programs in this lab have a main function that uses assert to test one or more other functions. All the changes are made in other functions in the program file.

      Set up

      Start by creating a lab06 directory to work in. Open a terminal window in your cs201/lab06 directory.

      Download these two [ bad.cpp ] [ p1.cpp ] skeleton files.

      Program 1 -- Debug a bad function

      Use the compiler to test "bad.cpp" -- then use your preferred editor to fix it. There are several Common Errors in this function.

      Program 2 -- Complete the given function

      Here you develop a function that would be quite useful to CSUSB and other organizations that give a standardized email to their people. The program "p1.cpp" has a set of tests and a description of the function -- it combines the initial of the first name with the second name and truncates the result to no more 8 characters. For example, my email is "rbotting".

      Update the leading documentation to show your name.

      Make the program compile and run to "Success" with out changing the main program in any way.

      Hint -- see pages 63 to 66 in our text book to see what you can do with strings.


      Show the lab teacher how far you have got with your two programs.

      If you have time -- work on the next project


  1. Gnu::="Gnu's Not Unix", a long running open source project that supplies a very popular C++ compiler.
  2. TBA::="To Be Announced", something I have to do.
  3. TBD::="To Be Done", something you have to do.