PIC 10a Spring 2007 Section 2b page.

Example files from section:

while1.cpp shows how you can use while(getline)
newtonsmethod.cpp a simple application of Newton's method, this gives an example of the use of while loops.
ifelse2.cpp checks to see if a 5 letter word is a palindrome, uses some string commands
failedgetline.cpp an example of a sneaky way that getline can screw up when used in combination with cin.
hw2example.cpp converts money into lincolns/washingtons/etc..
hw2example2.cppconverts money into lincolns/washing tons/etc..
convertchar.cpp uses static_cast to convert between int and char.
superfun.cpp an efficient video game.
whilenested.cpp demonstrates the exiting of nested while loops
whilenested2.cpp demonstrates the exiting of nested while/for loops
switch.cpp a program with a switch statement
switch2.cpp a program that simulates coin flipping
functions.cpp this has examples of how to declare/define functions
functions2.cpp examples of pass by value vs. pass by reference.
functions3.cpp a recursive function that computes n!
getValidInt.cpp shows how to use getline to clear out cin.
fibonacci.cpp a recursive function that computes Fibonacci numbers (note: 2 base cases)
recursion.cpp examples of recursive functions with some explaination of memory allocation
recursion1.cpp A recursion that counts the number of times that a string is found in some text.
factorai1.cppan example of a function that computes n!, and another function that messes it up.
pointers0.cppBasic pointers.
pointers1.cppPointers and objects.
pointers2.cppMore basic pointers.