#include #include using namespace std; using namespace std; void maxValue(int valuel, int value2, int max) { if (valuel > value2) max = valuel; else void maxValue(int valuel, int value2, int& max) { if (valuel > value2) max = valuel; else max = value2; } max = value2; } int main() { int main() { int max = 0; int max = 0; maxValue(1, 2, max); cout <« "max is " << max << end%; maxValue (1, 2, max); cout <« "max is " << max « endl; return 0; } return 0; } (a) (b)

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter2: Using Data
Section: Chapter Questions
Problem 14RQ
icon
Related questions
Question

What is pass-by-value? What is pass-by-reference? Show the result of the following programs:

 

#include <iostream>
#include <iostream>
using namespace std;
using namespace std;
void maxValue(int valuel, int value2, int max)
{
if (valuel > value2)
max = valuel;
else
void maxValue(int valuel, int value2, int& max)
{
if (valuel > value2)
max = valuel;
else
max = value2;
}
max = value2;
}
int main()
{
int main()
{
int max = 0;
int max = 0;
maxValue(1, 2, max);
cout <« "max is " << max << end%;
maxValue (1, 2, max);
cout <« "max is " << max « endl;
return 0;
}
return 0;
}
(a)
(b)
Transcribed Image Text:#include <iostream> #include <iostream> using namespace std; using namespace std; void maxValue(int valuel, int value2, int max) { if (valuel > value2) max = valuel; else void maxValue(int valuel, int value2, int& max) { if (valuel > value2) max = valuel; else max = value2; } max = value2; } int main() { int main() { int max = 0; int max = 0; maxValue(1, 2, max); cout <« "max is " << max << end%; maxValue (1, 2, max); cout <« "max is " << max « endl; return 0; } return 0; } (a) (b)
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Variables
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT