Which of the following must be true if there is a variable of the same name and
ID: 3812438 • Letter: W
Question
Which of the following must be true if there is a variable of the same name and type in main as in a function’s parameter list? For example,
double area(double radius)
{
return ( M_PI*radius*radius );
}
int main()
{
double radius = 3;
double a = 5;
cout << "Area: " << area(a);
return 0;
}
a. The value of the variable in the function area() will be the same as the value of the variable in main().
b. The variable in the parameter list must be a reference parameter.
c. The variable in the parameter list must be a constant.
d. This is a syntax error.
e. These are two separate data storage locations and except for having the same name are unrelated.
a. The value of the variable in the function area() will be the same as the value of the variable in main().
b. The variable in the parameter list must be a reference parameter.
c. The variable in the parameter list must be a constant.
d. This is a syntax error.
e. These are two separate data storage locations and except for having the same name are unrelated.
Explanation / Answer
e is the correct answer.
These are two separate data storage locations and except for having the same name are unrelated.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.