Weeks 6 and 7

In week 6, we continued with Chapter 4 (4.5 - 4.6) of the textbook (Tapestry) that we started in the previous week. Basically, we talked about strings and its member functions. The related lecture notes were posted under week 5.

In weeks 6 and 7, we covered loops from chapter 5 (5.1 and 5.2). First examples on finding sum of input numbers (sumnums and sum10nums) are not in the book. Moreover, drawing rectangle and triangle examples (nested loop examples) are not from the book either. Last example (robot example) is not in the book as well.  The first midterm exam covers until the end of loops.

Powerpoint file
loops.ppt

C++ codes discussed in class (some of them might have been modified in class to show extra features)

sum10nums.cpp
sumnums.cpp
revstring.cpp
palindrome.cpp
fact.cpp
bigfact.cpp
primes.cpp

drawfigures.cpp
multiply.cpp
rectangularscan.cpp

BigInt class files; needed for bigfact.cpp. Both files must be in the same folder as bigfact.cpp. bigint.cpp must be added to the project as an existing source file. bigint.h must be included at the beginning of the main program using #include "bigint.h"
bigint.h
bigint.cpp
 

strutils.cpp and strutils.h files are string utilities library of our book (Tapestry). In order to use this library, you have to copy both files to the same folder as your main cpp file. You also have to have #include "strutils.h" at the beginning of your program and add strutils.cpp file to your project as an existing source file. We mentioned about this library in class but did not use it in any example. In the recitations, you will see some examples that are using strutils. This library would be extremely useful in homework 4.
strutils.h
strutils.cpp
 

END OF MIDTERM 1
 

In week 7, we also covered reference parameters: This is Section 6.2.3. Examples covered in class are not from book, but given below.  However example program of the book is good. Please have a look at them. Reference parameters are not included in the 1st Midterm Exam.

Powerpoint file
params.ppt
 

C++ codes discussed in class (some of them might have been modified in class to show extra features)
passbyvalue.cpp
passbyreference.cpp
roots.cpp