#include <iostream>
using namespace std;
//hypthesis: I think that arg1 arg2 and arg3 will remain unchanged because a copy will be stored in the paramter variable and any changes will afect the copy not he original value.
void Change(int, int, int);
int main()
{
// 0. Print a message explaining the program;
cout << "\nThis program provides a 'laboratory' in which\n"
<< "experiments can be performed on parameter-passing.\n";
int arg1,
arg2,
arg3;
// 1. Initialize arguments to -1;
arg1 = arg2 = arg3 = -1;
// 2. Display Arg1, Arg2, and Arg3 (before Change);
cout << "\nBefore: arg1 = " << arg1
<< ", arg2 = " << arg2
<< ", arg3 = " << arg3 << endl;
// 3. Call Change, passing it Arg1, Arg2, and Arg3 are arguments;
Change(arg1, arg2, arg3);
// 4. Display Arg1, Arg2, and Arg3 (following Change);
cout << "\nAfter: arg1 = " << arg1
<< ", arg2 = " << arg2
<< ", arg3 = " << arg3 << "\n\n";
}
/*************************************************************************
* Change is the 'lab' in which we experiment with parameter passing. *
* *
* Specification: *
* receive(caller): 3 integers, stored in Param1, Param2, Param3; *
* return(caller): the (altered ???) values of Param1, Param2, Param3.*
*************************************************************************/
void Change(int param1, int param2, int param3)
{
param1 = 1;
param2 = 2;
param3 = 3;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: