In: Computer Science
1.) Discuss the rules involving actual parameter lists, including matching data types and a one-to-one correspondence with the formal parameter list. Note that the parameter list can be empty, but the function call will still require parentheses after the function name.
(2) Discuss scope rules with respect to global and local identifiers, nested blocks, and functions.
(3) Discuss how local declarations are stored in computer memory. Are there any reasons to avoid using local declarations if it is possible to achieve the same result without them?
1). ANSWER :
GIVENTHAT :
TO DISCUSS THE RULES INVOLVING ACTUAL PARAMETER LIST
Function name (Parameter1, Parametert2, …)
WHERE,
Function name: - is the name of the function to be called.
Parameters: - we can pass Parameters as many as needed, these are the actual values
on which the function will operate.
SUPPOSE IF THE DATA TYPE OF THE ACTUAL PARAMETER, AND FORMAL PARAMETER IS DIFFERENT, THEN THE COMPILER WILL SHOW ERROR AS WRONG DATA TYPE CONVERSION FROM ACTUAL PARAMETER TO FORMAL PARAMETER.
WITH ONE TO ONE CORRESPONDENCE BETWEEN ACTUAL AND FORMAL PARAMETERS, IT’S VERY EASY FOR THE COMPILER TO DECIDE WHICH VALUE IS PASSING TO WHICH FORMAL PARAMETER.
Note that the parameter list can be empty, but the function call will still require parentheses after the function name:
2).TO Discuss scope rules with respect to global and local identifiers, nested blocks, and functions.
3).TODiscuss how local declarations are stored in computer memory.
int a = 5;
THEN THE COMPILER CREATES A MEMORY SPACE OF ”4” BYTES OF SPACE AND NAME THAT LOCATION AS “a” AND STORE THE VALUE “5” IN IT.
Are there any reasons to avoid using local declarations if it is possible to achieve the same result without them?