Module 8 - Functions
In this module, we updated bisect_fn.c and mvp.c to use functions and pointers.
Can you see how functions would be beneficial for some of the other programs we've constructed?
Take a look back at mmp.c from Module 5.1; can you see ways to update this program to
- use functions to carve up the code into manageable, more coherent chunks?
- replace the arrays used for matrix-matrix multiplication with pointers?
Give this a try (you don't have to actually reconstruct, recompile and run the code, just take a look and see how you might accomplish the above). Then have a look at this Module's version of mmp.c;
- how did your version differ from mmp.c in this Module?
- where did you do something similar to this module's version of the code?
Now let's take a look at a more involved piece of code; Gaussian reduction covered in Module 5.2. Take a look at that module's version of gauss.c.
- How would you break this program up into functions?
- How would you implement pointers to handle the matrix computations?
Now take a look at the version of gauss_wo_pivot.c implemented in this Module.
- How close is this to your version?
- Did you do anything that you believe works better?
- Did you see anything in this module's version that you might use in the future?
After you've had a chance to immerse yourself in the concept of functions, you'll begin to develop your own way of breaking up the computations of a program into portions that make sense to you.
Some of these methods for 'chunking' program calculations are universal, but some will be specific and unique to you.
- What does this suggest to you about programming? (Hint: hopefully, you're thinking along the lines of "Commenting my code so that others can make sense of what I'm doing")
Continue to the Extend Section ->