Consider the following program. Assume all variables are declared and the program compiles. #include using namespace std; void getVal(int&, int&); void procVal(int, int&); int x; int main() { int intNum1; int intNum2; x = 6; getVal(intNum1, intNum2); cout << intNum1 << " " << intNum2 << " " << x << endl; procVal(intNum1, intNum2); cout << intNum1 << " " << intNum2 << " " << x << endl; return 0; } void getVal(int& a, int& b) { cout << “Enter value for a: “ << endl; cin >> a; /// The user enters 1 cout << “Enter value for b: “ << endl; cin >> b; /// The user enters 2 x = a * b; } void procVal(int u, int& v) { int intNum3; intNum3= x; v = intNum3 * 4; u = u - v; } Answer the following questions: Considering the function getVal, both parameters are called by reference. What is passed into the function for the parameters, i.e., what do the parameters receive? HINT: Do not write ‘a reference parameter or a reference value’!
- Consider the following program. Assume all variables are declared and the program compiles.
#include <iostream>
using namespace std;
void getVal(int&, int&);
void procVal(int, int&);
int x;
int main() {
int intNum1;
int intNum2;
x = 6;
getVal(intNum1, intNum2);
cout << intNum1 << " " << intNum2 << " " << x << endl;
procVal(intNum1, intNum2);
cout << intNum1 << " " << intNum2 << " " << x << endl;
return 0;
}
void getVal(int& a, int& b)
{
cout << “Enter value for a: “ << endl;
cin >> a; /// The user enters 1
cout << “Enter value for b: “ << endl;
cin >> b; /// The user enters 2
x = a * b;
}
void procVal(int u, int& v)
{
int intNum3;
intNum3= x;
v = intNum3 * 4;
u = u - v;
}
Answer the following questions:
- Considering the function getVal, both parameters are called by reference. What is passed into the function for the parameters, i.e., what do the parameters receive? HINT: Do not write ‘a reference parameter or a reference value’!
![](/static/compass_v2/shared-icons/check-mark.png)
void getVal(int& a, int& b)
{
cout << “Enter value for a: “ << endl;
cin >> a; /// The user enters 1
cout << “Enter value for b: “ << endl;
cin >> b; /// The user enters 2
x = a * b;
}
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)