CMPSC 101 Demos
CMPSC 101 Home

The following demo programs will be reviewed in each class.
However, there are many more relevant demo programs linked at the bottom of this page.

***************** Unit: Variables *****************

Class #1

hello world

Class #2

cout statements - displaying output with cout, endl, and \n

using variables - using variables, cin, declaration & assignment statements, comments

tic tac toe display board - using several cout statements to display a tic tac toe board

tic tac toe with variables - using 9 variables to represent positions of board

Class #3

special operators - modulus operator %, incrementing operator ++, compound operator +=

overflow integer division - illustrating nasty concepts of integer division, type casting, overflow, & underflow

macho rounding - a method of rounding that uses type casting

setf rounding - a method of rounding that uses cout.setf & cout.setprecision

***************** Unit: If Statements *****************

Class #4

if statement - using an if statement to control a menu

nested if statements   - using an if statement to control a menu & validating user input

tic tac toe board with if statement - using if statements to check for win in tic tac toe

***************** Unit: Loops *****************

Class #5

while loop 1 - running total

while loop 2 - running total with sentinel value to exit loop

while loop 3 - running total with sentinel value & flag variable to exit loop

while loop 4 - menu, running total with sentinel value & flag variable

for loop - can be adapted to a for loop that iterates different determinate amounts

***************** Unit: Functions *****************

Class #6

lots of easy functions - various functions

compute tax function -

void function - example of a function that doesn't return a value

Class #8

round function - rounding, compute tax, & a void functions

random numbers - using the rand library function.

moving on a grid - using a function that moves a player around a grid

***************** Unit: Files *****************

Class #9

reading from file - reading numbers from a sequential access file

reading and writing files - use of a while loop with eof function

appending to a file - appending data to the end of a file when writing data to it

***************** Unit: Arrays *****************

Class #10

array intro  -

array intro with loop -

Class #12

sequential search simple -

sequential search finding max value -

tic tac toe - using a one-dimensional array to represent a tic tac toe board

binary search -

***************** Unit: Strings *****************

Class #13

using string variables -

***************** Unit: Miscellaneous *****************

Miscellaneous

search engine -

Finch Robot demo 1 -


The following programs are relevant and appropriate for study in CMPSC 101:

variables

if's & loops

functions

files

arrays

strings