// ptr7.cpp By: Aiman Hanna - ©1993-2006 Aiman Hanna // This program concerns of passing parameters to functions in general. // // Key Points: 1) Are the parameters for the function below being passed by // value, or by reference? #include void Twice(int x , int y) { // This function accepts two integers as parameters and attempt to duplicate them. cout << "\n Starting \"Twice\"...." << endl; cout << " x now is " << x << "\n"; cout << " y now is " << y << "\n"; x *= 2; y *= 2; cout << "\n x after duplication is " << x << "\n"; cout << " y after duplication is " << y << "\n"; } int main() { int a[3]; a[0] = 4; a[1] = 5; a[2] = 7; cout << " This is the array before executing Twice \n"; for ( int i = 0 ; i < 3 ; i++ ) cout << a[i] <<"\n"; Twice(a[0], a[2]); cout << "\n\n This is the array ... after executing Twice !!!! \n"; for ( i = 0 ; i < 3 ; i++ ) cout << a[i] <<"\n"; return 0; } // The following is the result of compilation //Compilation successful // The following is the result of running the program /* This is the array before executing Twice 4 5 7 Starting "Twice".... x now is 4 y now is 7 x after duplication is 8 y after duplication is 14 This is the array ... after executing Twice !!!! 4 5 7 */