Question: c++ Note: Do not use using namespace std; Use std:: Use comments for clear understanding TEST THE PROGRAM. 1) Create a c++ program to run
c++
Note: Do not use using namespace std;
Use std::
Use comments for clear understanding
TEST THE PROGRAM.
1) Create a c++ program to run a simple experiment to see how reference parameters work. 2) You need to add a & symbol after the parameter type specification to set up a reference parameter: int myfunc (int & x) { x = 11; return -11; }
int testdata = 0; int y;
y= myfunc (testdata); 3) Now, You can get a normal return value from our function. But a hidden side effect is possible as well. If myfunc modifies the parameter variable (x in this case), the callers testdata will be modified. It is important.
Things to do: You are to build a project that has three files: main.cpp compare.cpp compare.h The Compare Function The compare.cpp file contains one function, also named compare. This function takes two integer reference parameters with names param1 and param2 and compares them. It returns a single character based on what it sees. Here is what you are to return: = if the two values are equal < if param1 is less than param2 > if param1 is greater than param2 Just to prove that the compare function really does have access to your callers variables, have the function flip the sign of each parameter before you process the return statement you need in this function: param1 = -param1; param2 = -param2; WarningThis will mess up your final output, but that is fine for what we are trying to see here!) The Main Function Set up the main program that asks the user for two integer numbers, which are stored in variables named var1 and var2. The main program then calls the compare function described above, passing in the parameters var1 and var2. Once you have the return character, you are to test that character and print out a more complete English statement about the result. For example, if you get back an equal sign character, you will print out this: 1234 is equal to 1234 Since you flipped the sign in the compare function, you will actually see negative values here, not the positive values the user entered). Add output statement similar to the above for the other two possible return characters.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
