
//Dione Torrevillas                 CS1A                 Chapter 9, P. 538, #5
/*
********************************************************************
POINTER REWRITE
Description: Rewrite the textbook's doSomething function so that
             it uses pointer parameters instead of references.
INPUT:       Two integer values.
OUTPUT:      The modified values and the sum returned by the function.
********************************************************************
*/
#include <iostream>
using namespace std;

// Change two integers through pointers and return their sum.
int doSomething(int *x, int *y)
{
    int temp = *x;
    *x = *y * 10;
    *y = temp * 10;
    return *x + *y;
}

int main()
{
    int first, second;
    cout << "Enter the first integer: ";
    cin >> first;
    cout << "Enter the second integer: ";
    cin >> second;

    // Pass the addresses of both integers to the function.
    int total = doSomething(&first, &second);

    cout << "First value after the function: " << first << endl;
    cout << "Second value after the function: " << second << endl;
    cout << "Returned sum: " << total << endl;
    return 0;
}
