next up previous contents
Next: Local Variables Up: Functions Previous: More about the Syntax   Contents


Homework Assignments (100 points, due one week from assignment date)

Use the program at http://www.drtak.org/teaches/ARC/cisp365/samples/factor.pas as a basis.

This program works (as you know already). However, it is somewhat of a taboo to refer to global variables in a subroutine (be it a function or a procedure). As a result, procedure find_factor_f_in_n is not as ideal as it could have been.

Your assignment is to fix this problem. You are to turn find_factor_f_in_n into a function that returns the factor. As a function, it should also take one (and only one) parameter.

You also need to change the main program so it calls a function instead of a procedure. In addition, you need to do something about the value returned by the function.

This is a summary of what you need to do (as a suggestion):

These are the absolute requirements of your program:

Submit the assignment to tauyeung@drtak.org with a subject line of ``CIS31 Project4 by My Name''.


next up previous contents
Next: Local Variables Up: Functions Previous: More about the Syntax   Contents
Tak Auyeung 2003-12-03