Last modified: Friday, December 9, 2016
swap_demo.cpp
fstream library
main function
demonstrating file output
out_play, with
the command: g++ out_play.cpp -o out_play main function
demonstrating file input
in_play, with
the command: g++ in_play.cpp -o in_play main function
demonstrating file input using getline
to read a whole line (as a string) at a time
inline_play, with
the command: g++ inline_play.cpp -o inline_play while loop, and example of a program using a
question-controlled-style while loop; briefly described
how to put ALL of a program's functions into ONE file
main function that we created (and re-created)
in NetBeans, Code::Blocks, and Dev-C++ during lab main function that uses a sentinel-
controlled loop to repeatedly call function cheer
until the user enters a negative number of hips main function that uses a question-
controlled loop to repeatedly call function cheer
until the user answers anything but y when asked
if they want to call it again
main function that uses a sentinel-
controlled loop to repeatedly call function cheer
until the user enters a negative number of hips main function that uses a question-
controlled loop to repeatedly call function cheer
until the user answers n when asked
if they want to call it again (with a snarky "bonus"
of complaining and making them try again if they
enter anything OTHER than y or n) for loops,
another array example, and started discussion of
sentinel-controlled and question-controlled loops
for loop for loop smallest_ck_expect, with the command: g++ smallest_ck_expect.cpp smallest.cpp -o smallest_ck_expect for loops
sum_array - example of a
function whose parameters are an array and its
size: sum_array_ck_expect, with the command: g++ sum_array_ck_expect.cpp sum_array.cpp -o sum_array_ck_expect while
loops, using the count-controlled while loop style
(just one of MANY a while loop can use!) -
also intro to several C++ "shorthand" operators, += -= *= /=
and ++ --; also started intro to C++ arrays
vertical - uses a
count-controlled while loop pattern
to loop through the characters in a string
(with the help of the string class
at method): vertical_test, with the command: g++ vertical_test.cpp vertical.cpp -o vertical_test main function playing around a bit with the
++ operator
plus_plus_play, with the command: g++ plus_plus_play.cpp -o plus_plus_play while
loops, using the count-controlled while loop style
(just one of MANY a while loop can use!)
cheer - a first example of a
count-controlled while loop pattern: cheer_test, with the command: g++ cheer_test.cpp cheer.cpp -o cheer_test sum_ints - uses a
count-controlled while loop pattern
to sum integers from 1 to a given integer: cin; started intro to iterative repetition in C++,
starting with
the while statement
main function that
provides an interactive front-end to
function rect_area (using
cin)
rect_area_ask, with the command: g++ rect_area_ask.cpp rect_area.cpp -o rect_area_ask main function demonstrating our first
cin to read a value into a variable
cin_demo1, with the command: g++ cin_demo1.cpp -o cin_demo1 main function demonstrating using
cin to read values into variables of different
types
cin_play, with the command: g++ cin_play.cpp -o cin_play say_sound
example; intro to
local variables/mutation/assignment
statements
say_sound
and its testing main:say_sound_test, with the command: g++ say_sound_test.cpp say_sound.cpp -o
say_sound_test char*
or char
literal using backslash;
using the design recipe but not funct_play
(with the help of the posted C++
templates!)
walked through creating function rect_area
and its main function tester in file
rect_area_test.cpp, and
and walked through creating our first void function
say_sound and its main function tester
in file say_sound_test.cpp
rect_area
and its testing main:rect_area_test, with the command: g++ rect_area_test.cpp rect_area.cpp -o
rect_area_test say_sound
and its testing main:say_sound_test, with the command: g++ say_sound_test.cpp say_sound.cpp -o
say_sound_test main function, and how to
compile C++ functions and programs from the command-line
main function,
a classic C++ "hello, world"-style main
function
hello, with the command: g++ hello.cpp -o hello main function in file
grade_in_range_test.cpp ,
that calls function grade_in_rangegrade_in_range_test, with the command:
g++ grade_in_range_test.cpp grade_in_range.cpp -o grade_in_range_test main function,
a classic C++ "hello, world"-style main
function
hello, with the command: g++ hello.cpp -o hello main function in file
greet_play.cpp ,
that calls function greetgreet_play, with the command:
g++ greet_play.cpp greet.cpp -o greet_play cout
play_around:string as a list of char;
is_empty:first:rest:silly_length:rest,
is_emptycount_vowels:first,
rest,
is_empty, and also is_vowel,
from the Week 9 Lab Exercise.
Its example solution
can be found on the course Moodle site, under
"Selected solutions"
funct_play and the design recipe
to design and write C++ functions using branching,
including C++ if and switch
statements
if-else-if pattern examples,
intro to the C++ switch statement
get_letter_grade
using funct_play, nano,
and funct_compile:get_letter_grade
uses grade_in_range from Week 8 Lab --
COPY
grade_in_range.h,
grade_in_range.cpp, and
grade_in_range_ck_expect.cpp into the same directory
as get_letter_grade!)
describe_grade
using funct_play, using an if-else-if
pattern:describe_grade, now using a switch
statement:if statement, the if-else-if
multi-way branch pattern
abs_value
using funct_play:next_sound
using funct_play:greet
using funct_play, nano,
and funct_compile:funct_play
(and then sometimes corrected and recompiled/rerun using
funct_compile...!); example of a string
class method and operator
circ_area, ring_area,
grade_in_range, and name_length
that were created in both labs, and example/recreated
examples of funct_play and
funct_compile runs creating
themcirc_area -
funct_play run, creating C++ function
circ_area, projected during class,
with what YOU'D type shown in bold circ_area - funct_compile run,
fixing and recompiling
circ_areacirc_area by
funct_play (and then fixed):ring_area - funct_play run,
creating C++ function
ring_arearing_area - funct_compile run,
fixing and recompiling
ring_arearing_area by
funct_play (and then fixed):grade_in_range - funct_play run,
creating C++ function
grade_in_rangegrade_in_range by
funct_play:name_length - funct_play run,
creating C++ function
name_lengthname_length by
funct_play:funct_play run, creating function
circ_area, projected during class,
with what YOU'D type shown in bold circ_area by
funct_play:check- operations
and file
input/output
check-range and check-member-of
list shortcut,
append function,
bringing in an image from a file or URL,
and intro to file input/output in
BSL Racket (via the 2htdp/batch-io teachpack)
random
function
big-bang's on-key clause,
another example using a cond expression
with enumerations
cond expression (and using cond-templates within
the design recipe); discussion of intervals
and enumerations; intro to in-comment data definitions (for
example, for enumerations);
cond/conditional expression (and using
cond-templates within the design recipe when you have
different categories of data)
scene
instance;
intro to the big-bang function in the teachpack
2htdp/universe;
intro to the modulo function
scene type,
example of a using the design recipe to write a function
that returns a scene instance
save-image function from 2htdp/image ~st10/111submit,
and more examples of operations you can use in compound
expressions in BSL Racket
Please send questions to: sharon.tuttle@humboldt.edu