SOURCE FILE: EX0304.CPP
//
// Example 3.4. Demonstration of how a function cannot change
// the contents of a pass by value parameter
//
#include <iostream.h>
int main(void)
{
void modify_i(int i); // prototype local to main
int i; // local to main
i = 1; // local variable is assigned 1
cout << "Before calling modify_i, i equals " << i << endl;
modify_i(i);
cout << "After calling modify_i, i equals " << i << endl;
return 0;
}
//
// Function to modify parameter i locally
// Pre: i is an integer.
// Post: none
//
void modify_i(int i) // i is local to modify_i
{
i = 3; // parameter is assigned 3
}