Week 4 Tutorial

In this weeks tutorial, you will be reviewing functions, variables, memory, and loops.

Assignment 0 is out!

Assignment 0 has finally arrived! Give a brief overview of what’s in the assignment spec and remind your class when its due. The full spec is available here.

Code review

Select a pair to present their “Sort 3 Numbers” code for review, from last week’s lab activities. The review should take about 10 minutes. The reviewees should give a brief description of their code, and the class should ask questions, comment on the quality of the code, and suggest improvements.

Function review

Make sure you know how functions work, how values are copied into functions, and how variables in one function are separate from another.

Look at favourite 2 from last week and discuss how variables work with the functions and how changing a variable in one function does not change the value in another.

Loops and repetition

Run through a basic example of using a while loop in C to count from one number to another.

Then look at using two loops to show a rectangle of fixed size.

Types and memory

Make sure to use gcc instead of dcc in this section to allow for overflow and underflow.

This week, the stuedents will complete Explore Memory in the lab.

During the tutorial, write a program, that uses the sizeof operator to show the size of the int type. This should show the size of the type in bytes. Discuss the other types that are available, such as:

Discuss the minimum and maximum values that some of these types can represent and how this relates to the size used to store the type. Also discuss, for the integer types, what unsigned means. You may want to discuss 2’s compliment when discussing signed and unsigned types. You may want to discuss how IEEE floating point values are stored when discussing float and double.

In the lab

IMPORTANT: Make sure students run 1511 pair when the get to the lab before starting any activities to ensure their lab partners are correctly recorded.