You are on page 1of 1

MEREDORES, CARL ANTHONY L.

19-1-00397

BSCE-02 FEBRUARY 03, 2021

LEARNING TASK 5.2

Questions:

1.Differentiate parameters and arguments

A parameter is a variable defined by a function that receives a value when a function is called. On
the other hand, an argument is a value that is passed to a function when it is invoked. As I think
about these two concepts, I see parameters as variables while I see arguments as expressions. For
example, in a function “AddTwonumbers (a, b)”, a and b are parameters and, in a function,
“AddTwonumbers (3,5)”, 5 and 3 are arguments.

2.When does function is executed?

To be able to execute a function, it is a must to undergo “function calling” for a function will not
be executed unless it is called. Function calls contain the name of the function that you want to
perform followed by the appropriate parameter which could be empty.

3. Differentiate local from global scope.

A scope is a region where variables can be declared. It is called local scope if you define a variable
inside the main block and so it is available only within that block. While it is called global scope
if you declare a variable outside the main block so it is available throughout the program.

4.Until when is the lifetime of a variable? In function and other parts?

From what I have seen online, scope equates to lifetime. It is the area for which the variable is
applicable or alive. The lifetime of a variable depends on how you define its scope. If you define
a variable as local variable inside a function, then it is only alive and accessible by the function
they are declared in. On the other hand, if you define a variable as global variable which means
that it is outside the main function, then this variable can be accessed by all functions in the
program and is alive throughout the program.

5.What are the flow of execution of functions?

As what I learned in experience, the execution always starts with the very first line of the program.
The interpreter performs or executes the code one at a time from top to bottom. When there is a
function, it does not change how the interpreter executes the code for it will only run the function
when it is called. However, when a function is called, it causes the interpreter to somewhat take
an alternative route. Instead of executing the next line, the flow jumps to the first statement within
the function and then executes all the available statements inside that function. After that, it comes
back to where it left off.

You might also like