#include using std::cout; using std::endl; int sqrByValue(int); void sqrByPointer(int *); void sqrByRef(int &); int main() { int x = 2, y = 3, z = 4; cout << "x = " << x << " before sqrByVal\n" << "Value returned by sqrByVal: " << sqrByValue(x) << "\nx = " << x << " after sqrByVal\n\n"; cout << "y = " << y << " before sqrByPointer\n"; sqrByPointer(&y); cout << "y = " << y << " after sqrByPointer\n\n"; cout << "z = " << z << " before sqrByRef\n"; sqrByRef(z); cout << "z = " << z << " after sqrByRef\n"; return 0; } int sqrByValue(int a) { return a *= a; // caller's argument not modified } void sqrByPointer(int *bPtr) { *bPtr *= *bPtr; // caller's argument modified } void sqrByRef(int &cRef) { cRef *= cRef; // caller's argument modified }