// Example 3.6. Example of functions using a global variable #include using namespace std; int i; // global int main() { void modifyI(); i = 1; // global i is assigned 1 cout << "Before calling modifyI, i equals " << i << endl; modifyI(); cout << "After calling modifyI, i equals " << i << endl; return 0; } // // Function modifies global i // Pre: i is a global integer variable. // Post: Global variable i has been assigned 3. // void modifyI() { i = 3; // global i is assigned 3 }