Class Crib Notes for CPSC 110 Brent Dingle
Friday, January 25, 2002
Reminders:
Homework and Quiz next week in lab.
Recall Algorithm Definition.
Recall Program Definition.
Card Trick:
Determine 2 unknown numbers via some ‘magic’
(2a + 5) * 5 + b – ???? reveals a and b.
Program Design to perform trick
Problem Solve phase
Prob definition
Find a and b using some math properties
Design phase
Write out algorithm
Test phase
Prove it will always work
Implementation phase
Code Algorithm
Write it out in Pascal
Discuss
PROGRAM, BEGIN, END = reserved words
program name = identifier
Variable = identifiers
Writeln, Readln = standard identifiers
Each line is a program statement
Assignment operator, :=
(assignment statement)
Variable types:
Ask for user name (String)
Ask for final number (integer)
Expressions
can be stuff on right side of :=
(math expressions)
Test code
Run it on random input data