CprS 157 Schedule
CprS 157 Class 8
CprS 157 Class 10

Functions
Chapter 7 - Class 9



Reading Some Sample Programs


//******************************************************************
// Welcome program
// This program prints a "Welcome Home" message
//******************************************************************


//******************************************************************
// NewWelcome program
// This program prints a "Welcome Home" message
//******************************************************************


//******************************************************************
// Activity program
// This program outputs an appropriate activity
// for a given temperature
//******************************************************************


//******************************************************************
// Activity2 program
// This program inputs any number of temperature values and, for
// each temperature, outputs an appropriate activity
//******************************************************************


//******************************************************************
// Graph program
// This program generates bar graphs of monthly sales
// by department for two Chippendale furniture stores, permitting
// department-by-department comparison of sales
//******************************************************************

These programs illustrate the use of a powerful technique for modularizing a program: function calls. Each function is responsible for implementing a clearly defined subtask. If a function requires input information in order to do its task, it is defined with formal input parameters, which are place holders for the actual values to be passed to the function when it is invoked (called). If the function is to return a value to its caller, the specification of the datatype of that return value becomes an integral part of the function declaration. The logical structure of complex computations can be made apparent in a computer program by the judicious use of function calls.
 
 

Programming Exercises

  Solve these exercises in class, to your own satisfaction. When called for, create the appropriate data files and test your program on your data. Demonstrate your solutions to the instructor or to the class TA. There is nothing to hand in from this activity.
 
 

Homework For Chapter 7

  Everyone should write a calender program at least once in her life, and here is a great opportunity! Write a clear and correct solution to this programming problem. Think (and design your program) in terms of small building blocks that fit together well. Place an electronic copy of your work into the CS157 drop box before the beginning of our next class. Personalize the results of your efforts by using the file-naming conventions explained in class.