When parameters are passed between the calling code and the called function, parameters and arguments are matched by:
a. their data type
b. their relative positions in the parameter and argument lists
c. their names
d. they are not matched up at all
Which of the following are valid function calls to the tabs function?
b. cout << fabs(3.5);
c. cin >> fabs(3.5);
d. fabs(cin >> x);
e. a and b
What is the value of i after the following function call?
int doSomething(int value)
value = 35;
//fragment of main program
cout << doSomething(i);
Ah, what the heck:
As for the first question, I'm guessing on this one as I totally forgot.
As for the second question, the reason why it's A and B is because:
if the function fabs returns nothing, then a call to fabs(3.5); would indeed be legal. Otherwise, if it returned something, a variable of some sorts has to receive the returned value (like x = fabs(3.5); ). Hence, the cout << fabs(3.5) ; is legal.
The second one, duh, it's 35. You pass a value to the parameter "value" yet you initialize the value of "value" to 35, regardless of what number you pass into the function doSomething(). Hence, it's B.