Need help with these study question 1. Here is the prototype for a function name
ID: 3863176 • Letter: N
Question
Need help with these study question
1. Here is the prototype for a function named computeValue:
void computeValue(int);
Which of the following is a correct call (invoke) to this function?
void computeValue(int x);
2.
What is the output from the following piece of code?
#include <iostream>
using namespace std;
void copy (int& a, int& b, int& c);
int main ()
{
int x = 5, y = 3, z = 7;
copy (x, y, z);
cout << x << " & " << y << " & " << z;
return 0;
}
void copy (int& a, int& b, int& c)
{
a *= 2;
b *= 2;
c *= 2;
}
3.
What is the output from the following piece of code?
#include <iostream>
using namespace std;
void copy (int& a, int b, int& c);
int main ()
{
int x = 5, y = 3, z = 7;
copy (x, y, z);
cout << x << " & " << y << " & " << z;
return 0;
}
void copy (int& a, int b, int& c)
{
a *= 2;
b *= 2;
c *= 2;
}
4.A function can have zero to many parameters, and it can return this many values:
computeValue(10)Explanation / Answer
Question 1:
Answer is: computeValue(10);
here computeValue() is call with a parameter of integer value and end with ';' semicolumn
Question 2:
Answer is: 10 & 6 & 14
all the values are doubled because a,b,c are passed by reference so any changes done to a,b,c will refect to original values in main()
Question 3:
Answer is: 10 & 3 & 14
all the values are doubled except b because b are not passed by reference so any changes done to a,c will refect to original values in main() but not b
Question 4:
Answer is: no more than one
int function1(int n1,int n2,int n3 ..... int nn)
here the function can return only single value at the end.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.