/*******************************************************************************
* Aiden Stannard // CS1A // Chapter 9 Homework: Challange 5# // 11/21/2026
* _____________________________________________________________________________
*
* SWAP FUNCTION
* _____________________________________________________________________________
*
* This program accepts two different values for x and y, swaps the values of x
* and y, and than outputs the new swapped values of x and y, aswell the the sum
* x and y.
*
* Inputs: Enter a value for x:__
* Enter a value for y:__
*
* Output: The value of x is now__
* The value of y is now__
* The sum of x and y is__
*
******************************************************************************/
#include <iostream>
using namespace std;
int doSomething(int*, int*); // swap function prototype
int main() {
int x;
int y;
int z; // Stores value returned by the function
cout << "Enter a value for x: " << endl;
cin >> x;
cout << "Enter a value for y: " << endl;
cin >> y; // assigned console input into x and y
z = doSomething(&x,&y); // passes the value of x and y into a swap function
cout << "The value of x is now " << x << "\n The value of y is now " << y
<< endl; // Displays the swapped values of x and y
cout << "The sum of x and y is " << z << endl;
return 0;
}
int doSomething(int *x, int *y){
int temp;
temp = *y;
*y = *x;
*x = temp;
return *x + *y;
}