Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Write a complete C++ program with the two alternate functions specified below

ID: 3629030 • Letter: 1

Question

1. Write a complete C++ program with the two alternate functions specified below, of which each simply triples the variable count defined in main. Then compare and contrast the two approaches. These two functions are

a) Function tripleCallByValue that passes a copy of count call-by-value, triples the copy and returns the new value.

b) Function tripleByReference that passes count with true call-by-reference via a reference parameter and triples the original copy of count through its alias (i.e., the reference parameter).

Need help on this one please!, i know there are two seperate questions but not sure how to put them together. having difficulites. Willing to pay for the answer. i am learning program fundamentals 1. thank you very much.

Explanation / Answer

please rate - thanks

#include <iostream>
using namespace std;
int tripleCallbyValue(int);
void tripleCallbyReference(int&);
int main()
{int count=3;
count=tripleCallbyValue(count);
cout<<"After call by value, count= "<<count<<endl;
tripleCallbyReference(count);
cout<<"After call by reference, count= "<<count<<endl;
system("pause");
return 0;
}

int tripleCallbyValue(int count)
{int t=count*3;
return t;
}
void tripleCallbyReference(int& count)
{count*=3;
}