Lecture 17: Functions 3
Thursday, October 27, 2011 Status: complete[Up] [Previous Lecture] [Next Lecture]
Powerpoint Slides: none
Reading Assigned:
Homework Due:
Homework Assigned:
Topics Covered:
- Return and discuss Quiz 2.
- Finish up local variables.
- Parameter passing by reference.
- Classwork 17.
Programs Shown:
-
Uninitialized local variables have garbage value:
garbage1.c
and
garbage2.c.
THESE TWO PROGRAMS DEMONSTRATE A VERY BAD BUG. DO NOT COPY. - If formal parameters and actual parameters do not have the same type, the C compiler tries to convert the values if it can: promote.c.
- We try to write a function that swaps the values in two varialbles:
-
Here's an artificial example to help us understand reference parameters:
ref_par.c.
- This example includes a function that determines how many hours and minutes make up a given number of minutes: minutes.c.