Question: In C++ Cut and paste this program into a program called ex42.cpp, compile then run it. Which one of the values, i or j, got

In C++

Cut and paste this program into a program called ex42.cpp, compile then run it. Which one of the values, i or j, got updated upon return from the function process? What would you do to get both values updated upon your return to the main? make the necessary changes and run the program to make sure it works correctly.

program:

#include using namespace std;

// This is the declaration for the function that reads the values for i and j void get_input(int& i, int& j);

// This is the declaration for the function that adds 10 to i and 20 to j void process(int& i, int j);

int main() { int i, j;

get_input(i , j);

cout << "I am about to call function process, i = " << i << " j = " << j << endl;

process(i,j);

cout << "I just came back from function Process, i = " << i << " j = " << j << endl;

return 0; }

void get_input(int& i, int& j) { cout << "Please enter two values for i and j separated by a single space, then press :"; cin >> i >> j; cout << endl; return; // a void function, returns nothing }

void process(int& i, int j) { i = i +10; j = j +20; cout << "Inside function Process "; cout << "I added 10 to i, and 20 to j, i = " << i << " and j = " << j << " ";

return; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!