SOURCE FILE: EX0307.CPP
//
// Example 3.7. Example of a global variable and local
// variable with the same name
//
#include <iostream.h>
int i; // global
int main(void)
{
void modify_i(void);
i = 1; // global i is assigned 1
cout << "Before calling modify_i, i equals " << i << endl;
modify_i();
cout << "After calling modify_i, i equals " << i << endl;
return 0;
}
//
// Function modifies local i
// Pre: none
// Post: none
//
void modify_i(void)
{
int i; // local i
i = 3; // local i is assigned 3
}