Last modified: Friday, December 12, 2025
if
and for statementsif
and for statements void function, and also
uses a switch statementif and while statements, and
uses of the function getline and the file stream
method fail++ and --;
example of a void function; intro to
getline function; examples of how to read
everything from a file; and added some notes after class about
how to use the file stream fail method to check
if opening a filestream failed or not
void function
assn_header - a void function
that just has the side-effect of printing out a custom
assignment heading, and returns NOTHING
+= -= *= /=
and ++ --; intro to the classic C++ for
loop; intro to the basics of C++ stream-based file input/output
sum_array
to now use a "classic" for statement and a couple
of the C++ "shorthand" operators, and tested it in the
main function at the end; the main
function also includes demos of writing to and reading from a file
sum_array - refactored to use a "classic"
for statement and some C++ "shorthand" operators
main function, also! We just
happened to demo it from
a main function!++
and -- operators:for statement
break
like they do
here...! You will lose points if you do.)
main function at the end
sum_array - a function that has an array
parameter (amongst its two parameters)while statements, including using one
with a non-numeric loop control variable and using one
to "walk" through a string
while statement
with a non-numeric loop control
variable to let user specify how many cheers they want,
and also tests the two new functions created during class
using the design recipe
cheer - (copied from 111lect13-1.cpp) -
a function with side-effects,
printing a cheer to the screen, that
uses a while statement/loopsum_ints - a regular function that
uses a while statement to compute the sum of
the natural numbers from 1 to a specified valuevertical - uses a
while statement to loop through
characters in a string, printing them each on their
own line as its side-effect, and returns the
number of characters printedwhile statement/loop
while loop syntax, along with
a flow-chart showing while loop semantics
main function that both
plays around a bit with local variables and mutation
and tests a new function, cheer:
cheer - a function with side-effects,
printing a cheer to the screen, that
uses a while statement/loopwhile statement - has
additional discussion and
examples of while statements:
https://runestone.academy/runestone/books/published/thinkcpp/Chapter6/the_while_statement.html cin for interactive input
describe_grade with a main
function that uses cin to provide an
interactive front-endswitch statement;
started intro to local variables, assignment
statements, and mutation
main function at the end;
describe_grade - which includes
three versions, two of which use a switch
statement switch statement -
has some useful discussion and
exercises for these:
https://runestone.academy/runestone/books/published/thinkcpp/Chapter13/switch_statement.html switch and when to use
if-else-if pattern - with thanks to Casey Cooper!if statements, including using the
if-else-if pattern; intro to the C++
string class methods named substr;
STARTED function display_name
if - syntax and semantics if
with optional else - syntax and semantics if-else-if pattern - accepted alternate
indentation and semantics main function at the end, along with trying out
the C++ string class' substr methods
porridge_state - which happens to involve
interval-style datadisplay_nameif statement
main function at the end, and also a
little additional "playing around" in the main function:
name_length -
which calls a string
method, length
abs_value - which uses an
if-else
statement, and involves interval-style datanext_sound - C++ version of Week 4 - Lecture 2
Racket function next-sound, and involves
enumeration-style dataif statement syntax,
and its semantics expressed as a flow-chart if statement with optional else
syntax,
and its semantics expressed as a flow-chart if-else-if pattern - an alternate approved
indentation for a common use of "chained" if
statements appropriate when choosing exactly ONE of 3 or more
choices,
and its semantics expressed as a flow-chart string class return statement,
the definition of a C++ block,
more CS 111 class coding standards, a few debugging
tips,
another example of a C++ (non-main) function
designed using the design recipe and run and tested using the CS50
IDE, and intro'd the C++ string class's/type's
+ operator for appending
main function from Week 9 - Lecture 2, tested in the
main function at the end, also including post-class
demos of the C++ string class's/type's
+ operator for appending
grade_in_range - which returns a
bool value .cpp file template INTO a
.cpp file
in the CS50 IDE at
https://cs50.devmain) function
using the design recipe, including testing it in a main
function
circ_area,
tested in the main function at the end
.cpp file template INTO a
.cpp file
in the CS50 IDE at
https://cs50.devcheck_within
and main demo prints to
standard output when that is redirected into a file
2htdp/batch-io
module, another example of a function that "walks through" a list,
and another function allowing keystrokes to change a
big-bang world, here a world whose type is
a list of images
draw-images-randomly add-shape 2htdp/batch-io
file input/output module's read-lines and read-words
functions
len add1-list big-bang expression; review
clicker questions followed by a lab exercise
list type, and
introduced several built-in functions that work with lists
double-it big-bang's on-key clause;
intro to itemization data, and describing such
data using data definition
comments
draw-penguin-scenechange-elevation big-bang world of type string
draw-string-world next-sound - copied here, because
used in an example
-
change-world-string
-
time-to-quit?
cond
expression;
"falling" penguin example using
cond; discussion of interval-style data and
enumeration-style
data; walked through an example using enumeration-style data
draw-penguin-scene next-sound cond
(conditional/branching) expression; writing a boolean
function to use with big-bang
function's stop-when clause
cyan-star (copied from Week 2 Lecture 2)cyan-star-scene (REFACTORED a bit from
Week 3 Lecture 2 version) banana-report bad-star-size? scene;
example using the design recipe to write a function
that returns a scene instance;
intro to the big-bang function from the module
2htdp/universe
big-bang
calls at the end, it also defines the functions:
cyan-star (copied from Week 2 Lecture 2) cyan-star-scene humboldt-logo
and doubt-it; started intro to Racket's
scene type
humboldt-logo doubt-it check-expect; intro to writing your own
functions using the DESIGN RECIPE
triple cyan-star