Look at the below code and answer the following questions in
Solution
Please follow the Data for decription :
7)
a)
The code given consists of a function and then a main function, the function declared outside the main function has a datatype of int that has to be returned after the successful execution of the function, this could be clearly depicted from the datatype that has been initialised before the method name which is int in this case.
int increment (int a);
The above line clearly makes informative that the method name is increment and that takes a integer variable with the return type mentioned as the int.
b)
There is not any return type data or the line declared in the main function for the given code, but when the data needs to be returned over the main function then it is to be noted that the value that is returned makes the process of execution to be conveyed as the successful or an unsuccessful based on the execution like the represents that the code execution is successful and the - or the indicates that the code has some bugs and that needs to be fixed.
c)
Yes the line 2 in teh code get compiled successfully without any exceptions or errors but the line do not gets executed as the value of the function returned before this line\'s execution making the code unavailable to the function.
8)
In the context of programming languages the word scope in any programming is a region of the program where a defined variable can have its existence and beyond that variable it cannot be accessed. These are categorised into three types as follows :
If the variable is declared inside a function or a block then it is called as a local variables.
If is declared outside of all functions it is called global variables.
If is in the definition of function parameters the they are called formal parameters.
The variables that are declared inside a function or inside a block are called local variables. They can be used only by statements that are inside that function or block of code. Local variables are not known to functions outside their own.
9)
Global Variables / Global Scope :
Global variables are defined outside a function, usually on top of the program. Global variables hold their values throughout the lifetime of your program and they can be accessed inside any of the functions defined for the program. A global variable can be accessed by any function. That is, a global variable is available for use throughout your entire program after its declaration. The following program show how global variables are used in a program.
Local Variables / Local Scope :
The variables that are declared inside a function or inside a block are called local variables. They can be used only by statements that are inside that function or block of code. Local variables are not known to functions outside their own.
This definition clearly conveys that the main feature that maskes the global scope more important is it s availability throughout the program irrespective of the methods, functions, code.
Hope this is helpful.

