Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

R5.1 Why do local variables lose their values between calls to the function in w

ID: 3911280 • Letter: R

Question

R5.1 Why do local variables lose their values between calls to the function in which they are defined?

R5.2 When a function accepts multiple arguments, does it matter in what order the arguments are passed?

R5.3 What is the difference between an argument and a parameter variable?

R5.4 The _______________ is the part of a function definition that shows the function name, return type, and parameter list.

R5.5 The ___________ statement causes a function to end immediately.

R5.6 Write a function called timesFive that accepts an integer argument.   The function body should display the product of its parameter multiplied by 5 before returning to the calling function (e.g. main).

R5.7 TRUE or FALSE: Function headers are terminated with a semi-colon.

R5.8 TRUE or FALSE: In passing data by value, changes to the function parameters will affect the original argument as well.

Explanation / Answer

If you post more than 1 question, as per chegg guidelines I have to solve only first question.

R5.1 : The local variables are only valid in the local context or in other words there scope is only valid in the block they are defined. Outside of that block, the variables becomes out of scope and the memory alloted to them is freed.

R5.2 : The order in which the aguments does matter.

e.g: For function

void fxn(int a, int b , int c);

For the variables

int a = 1;

int b = 2;

int c = 3;

The function calls

fxn(a , b, c);

fxn( a , c , b );

are different.

Hence, the order the matters.

R5.3: Parameter variable is the variable that is present in the definition of the function.

  Argument is the actual variable that is passed while calling the function.

R5.4: Answer : function header

The function header is the function definition before the main() function. It is a must as we need to declare the function before the main() function.

R5.5 : return

The return command automatically stops the execution of the function and go back to the point where the function was called.

R5.8 : False

If the parameter is passed by value, then any change to it in the function will not affect the original value of the argument.