Warm up exercises:

how many times is the statement x = x+1 executed in the following

x = 0; 
for( j = 0; j < 10; j++) 

	for (i = 0; i < 5; i ++)

		x = x + 1;

cout << "x = " << x << endl;

 

Suppose a file contains all integers in proper form.


Chapter 7 - Functions

Lets take a look at the use of functions in some of the labs you've done.

General issues involving functions

----------------------------------------

What are the values stored in x, y, and z after the following is executed

x = 10;  
y = 20;

ExamPrep (x, y);

where ExamPrep is defined as

int ExamPrep( int p1, int & p2)
{
	if (p2 = p1)
		return p2;
	else if (p2 > p1)
		return p1;

	else	

		return p1 * p2;
}

Write a function that reads from and returns the sum of the input values stopping when either (or both) of the following conditions is met

 

-------------------------------------------------------------------

Take a look at some of the programs from the text in Chapter 8.


Function Overloading
Add a Debug function to display the values of an object of type PersonType.

Function Templates

Copy ~ernie/220/templateFunc.cpp to your directory. Modify it so that the program determines minimum values rather than maximum values.

Some problems to consider


Lab 5


Topics for upcoming test

Review questions


Creative Commons License
This work is licensed under a Creative Commons License.
Ernest Ackermann Department of Computer Science, Mary Washington College
CPSC 220 | CPSC 401

Bibliographic Information:
.