#include using namespace std; // Each function "stands alone" // All variables are in their own scope // (i.e. the scope of function1) // function1 only has a, c, and d as // variables in its scope int function1( int c, int d ) { // memory ==> c: 6 d: 5 int a = 6; // a: 6 c = d + a; // c: 11 d: 5 d = c; // c: 11 d: 11 // changing the values of c and d // do NOT change any variable in main() return d; // return the value of d (i.e. 11) } int function2( int e, int f ) { // e: 5 f: 11 e = f * e; // e: 55 f: 11 f = e * 6; // e: 55 f: 330 return e; // return 55 } int main() { // memory ==> a: 2 b: 5 int a = 2, b = 5; int g = function1( a+4, b ); // g: 11 // values a+4 and b (i.e. 6 and 5) // are "passed by value" to function1 cout << a << " and " << b << " and " << g << endl; a = function2( b, g ); cout << a << " and " << b << " and " << g << endl; // ==> 55 and 5 and 11 return 0; }