csc201 20100929 Notes

Posted in csc201 by bnmng on 2010 09/29

Passed out homework due Wed Oct 6

Reading Assignment: Read Chapter 9.1 to 9.3, 10.1 & 10.2

Today: Chapter 8,
function decomposition
syntax & semantics
call by value and call by references
files as arguments.
Chapter 9: Value yielding functions
boolean function

When to use functions? Not to improve the efficiency of the machine.
a) To make code easier to reuse
b) To make the task easier by breaking it down.

Functions should be specific. If you have a function that multiplies, it shouldn’t also write. Keep separate functions for separate tasks.

Example Function with Arguments

void PrintLines (int) ; //Prototype
int main ();
	cout <<" Welcome Home!" << endl;
        cin.get(); cin.get();
        return 0;
void PrintLines (int numLines)
	for (int count = 1; count <= numLines; count++)
           count << "*******************" << endl;


Calling by reference
When we use call by reference, you can think of it as passing an address.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: