Lecture #18: Review
November
12, 1999
Bob
Pitha
lectures
Lecture
2: Computers and computer languages
Basic
terminology
Computer
numbering
binary
octal
hexadecimal
What is a
computer program?
Computer
languages
Lecture
3: How is programming like driving?
That
driving directions analogy
Example
program: Hello, world!
Lecture
4: The C Language
A second
example program: printing numbers
variables
loops
Introducing
variables and data types
identifiers/variable
names
why have
data types?
integer
types
Lecture
5: Data Types
The 7 basic
data types
FtoC example
program
Lecture
6: More Data Types and Constants
signed/unsigned
data types
constants
numerical
constants
character
constants (which are numbers, too!)
escape
sequences
Lecture
7: Declarations
variable
declarations
initialization
Lecture
8: Operators
operators
and expressions
expression
concepts
lvalues!!!
conversions
in expressions
precedence
and associativity
arithmetic
operators
Lecture
9: More operators
increment/decrement
operators
assignment
operators
relational
operators
Lecture
10: Operators, expressions, statements
equality
operators
logical
operators
expressions
statements
expression
statements
compound
statements
Lecture
11: Statements 2
selection
statements: if-else
Lecture
12: Statements 3
the
conditional expression
selection
statements: switch
iteration
statements (loops)
while
for
Lecture
13: Statements 4
iteration
statements
do-while
jump
statements: break and continue
Lecture
14: Writing Programs
interpreting
a program
multiplication
table example
writing a
program
printing
prime numbers
Lecture
15: Quiz answers and discussion
Lecture
16: Functions 1
Lecture
17: Functions 2
textbook sections
Chapter
1: A Tutorial Introduction
this isnt
necessary, but it does give some decent examples.
Chapter
2: Types, Operators, and Expressions
weve
covered basically everything except the bitwise operators (§2.9)
dont worry
about subjects we havent addressed in class:
§2.3:
strings and enumeration constants
§2.4: const
declarations
Chapter
3: Control Flow
weve
covered the whole chapter
it contains
valuable information and examples
they use
getchar()
§3.8 Goto
and Labels
this isnt
critical material, but its good to know
Chapter
4: Functions and Program Structure
§4.1 4.4
§4.2 uses
arrays in its example
exercises
Consider
trying the exercises in your text, especially:
Chapter 1
1-1 1-5
Chapter 2
2-2, 2-10
Chapter 3
3-1
review questions
These
questions are just to help you review:
What does
the line #include <stdio.h> do for us?
Why do we
use comments?
What are the
largest and smallest values that can reliably be stored in a:
char
int
What is the
difference between the constants 6 and 6?
What are the
two different kinds of division that the / operator can do? Under what
circumstances does it perform each of them?
Name at
least two different uses for the semicolon in C
what would
the equivalent code, using a while loop, be for this example:

What is the
numeric value of the expression 3<4?
Under what
conditions will this code print water?

What would
this code print?

What would
this code print?(Caution: trick question!)

What do
these loops print?




What is the
difference between a function declaration (prototype) and a function
definition?
What is the
difference between the prefix and postfix forms of the ++ operator?
(trick
question) What would the expression

do?
Write a
program to print the numbers from 1 to 10 and their squares, like this:

You should use a function to
compute the squares of the numbers. It might have the following declaration:

Write a
program that prints a triangle, like this (using loops, not just a bunch of
printf statements!):

Write a
function that computes and returns the average of five numbers, which are
passed in as arguments. The function should be declared like this:

Write a
program that prints the numbers between 1 and 10, along with an indication of
whether each is even or odd (you can use the % operator). Your output should
look like this:
