What is the Function call, functions prototype, and the function definition of t
ID: 3643312 • Letter: W
Question
What is the Function call, functions prototype, and the function definition of the following program? Are the vairables being passed by value or passed by reference- identify each.#include <iostream>
using namespace std;
int x;
void mickey(int&, int);
void minnie(int, int&);
int main ()
{
int first;
int second = 5;
x = 6;
mickey (first, second);
cout << first << " " << second << " " << x << endl;
minnie (first, second);
cout << first << " " << second << " " << x << endl;
system ("pause");
return 0;
}
void mickey (int& a, int b)
{
int first;
first = b + 12;
a = 2 * b;
b = first + 4;
}
void minnie (int u, int& v)
{
int second;
second = x;
v = second;
x = u + v;
}
Explanation / Answer
// Function call
mickey (first, second);
minnie (first, second);
// Function prototype
void mickey(int&, int);
void minnie(int, int&);
// Function Definition
void mickey (int& a, int b)
{
int first;
first = b + 12;
a = 2 * b;
b = first + 4;
}
void minnie (int u, int& v)
{
int second;
second = x;
v = second;
x = u + v;
}
// For mickey first is being passed by reference (ie &) and second by value
// For minnie second is passed by reference and first by value
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.