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

Assume the following two functions have been declared: int f(int& x, int y) { X

ID: 3559953 • Letter: A

Question

Assume the following two functions have been declared: int f(int& x, int y) { X += 2; return x + y; int g(int x, int y, int z) { z = X * Yi return x + y + z; If in the main program all the following variables are defined as ints, what output does the fol-4>wing code in the main program produce? , '}- ) V A. [2] a = 1; b = 2 ; c = 4; , ._ '"]. I x = f (a, b); ) y = g(a, b, c); cout << x <""= endl; 1 v l cout << y << endl; cout << a << b << c << endl; B. [2] Assume that int& x in the definition for function f is replaced with int x. What output will the code from 4A above produce now?

Explanation / Answer

#include <iostream>
using namespace std;
int f(int& x, int y) { x+= 2; return x + y; }
int g(int x, int y, int z) { z = x * y; return x + y + z;}

int main() {
   int a = 1,b=2,c =4;
   int x = f(a,b);
   int y = g(a,b,c);
   cout << "x="<<x <<endl;
   cout<<"y="<<y<<endl;
   cout <<"a="<<a<<" "<<"b="<<b<<" "<<"c="<<c<<endl;
   return 0;
}

/*output*/

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote