WEEK05
June 7 and June 9
This page contains lectures, examples and assignments for week 5
of the class "Introduction to Scientific Programming".
Lectures:
-
Lecture #9, "Characters and the SWITCH Statement"
-
Lecture #10, "The Math Library, Functions and Parameters"
Examples:
-
average.cpp,
a program which shows how a CHAR variable can be used to store a letter
grade, based on the average score entered by the user.
-
char_arith.cpp,
a program which shows how a CHAR variable can be assigned a literal character,
or the result of a formula involving a character and a (small) integer,
or a small integer.
-
character_count.cpp,
a program which shows how we can read and count characters using
the cin function.
-
character_count2.cpp,
a program which shows a better way to read and count characters using
the cin.get() function, so that we "catch" spaces, tabs,
new lines, and so on.
-
compare.cpp,
a program which uses a user-defined function my_max() to compare
two numbers input by the user.
-
day_count.cpp,
a program which computes the number of days from some point in the past
til today.
-
frequency.cpp,
a program which reads input until terminated by an end of file.
It counts the number of lower or uppercase letters 'E' and 'T',
and at the end prints the counts.
-
gettysburg.txt,
the text of the Gettysburg Address.
-
grade.cpp,
a program which reads a letter grade and prints out the range of
scores that will achieve that grade.
-
longest_word.cpp,
a program which reads input until terminated by an end of file.
It keeps track of the longest word encountered.
-
poker_hands.cpp,
a program which tries to compute the number of possible poker hands
by using functions called choose() and factorial().
Unfortunately, the numbers coming out of the factorial function
make our program fail!
Assignments:
-
In class exercise #5, on Tuesday: ETAION SHRDLU
-
Program Homework #3 is due on Thursday. Please mail your program and output
to Detelina, or turn in printed copies.
-
Program Homework #4, to be assigned on Thursday.
You can go up one level to
the ISC course page.
Last revised on 06 June 2011.