CS 101: Code Examples
This page links to code examples presented in class.
Date | Code example | Description |
---|---|---|
Jan 24 | date.cpp | Read month/day/year and print them as a date |
Jan 26 | average.cpp | Read three values and print the average |
Jan 31 | accel.cpp | Compute Tesla acceleration 0-60 in multiples of G |
Feb 9 | ticket2.cpp | Ticket discount using if/else if |
Feb 16 | factors.cpp | Find factors of an integer |
Feb 21 | combo.cpp | Try to guess combination before bomb explodes |
Feb 21 | guess.cpp | Guessing game using while loop |
Mar 7 | rectangle.cpp | Print rectangle using text characters |
Mar 7 | box.cpp | Print outlined box using text characters |
Mar 7 | box-2.cpp | Same as above (box.cpp), alternate logic, with comments |
Mar 9 | prime-or-factors.cpp | Factors for a given number, with comments |
Mar 9 | checkerboard.cpp | Checkerboard of ‘X’s and ‘O’s, with comments |
Mar 21 | random-array-stats.cpp | populate array with random integers, then compute array stats |
Mar 21 | temperature.cpp | Read temperatures, compute average/min/max |
Mar 28 | functions.cpp | Calling a function to draw an outlined box |
Mar 30 | functions2.cpp | Program defining and using a factorial function |
Apr 18 | pointer.cpp | Compute power of 2 using function with a reference parameter |
Apr 20 | complex.cpp | struct Complex data type, functions |