Computer Science Questions and Answers: C-Programming (Function) Part - 11

1. What is a function?
A function is a small segment of the program(sub program) designed to perform a specific task and return a result to the main or calling program.

2. What are the different types of functions supported in “C” language?
C supports two types of functions. They are 1. Built-in / Library functions 2. User defined functions

3. What are library functions?
Some of the operations are programmed and stored in C library so that they can be called in the program. These functions are called as library functions.  Eg : printf(), sqrt(), pow()

4. What is a user defined function?
A user-defined function is a complete and independent program unit, which can be used(or invoked) by the main program or by other sub-programs.

5. Mention the need for a function
If there are a number of statements that are repeatedly needed in the same program at different locations,then a function may be used.

6. What do you mean by a calling function?
Once the function is created it can be called from the main program or from any other function. This main program or the function which calls another function is
called calling function.

7. What is a called function?
The user-defined function which is called by the main program or from any other function is known as called function.

8. What does the return-type-specifier of a function identify?
 It identifies the type of value, which will be sent back after the function has performed its task (eg: int, float).

9. Why is the return type void used?
The return type void is used if the function does not return any value to the calling function.

10. What is an argument?
Information or values are passed to the function through special identifiers are called arguments.

11. What are actual parameters? 
The arguments (values) which are passed to the function when a function call is made are called actual parameters.

12. What are formal parameters?
The arguments which are used in the argument list of the function header to receive the values from the calling program are called formal parameters or dummy
parameters.

13. Give the syntax of a function call?
A function call has the following syntax: variable = function_name(arg1,arg2…); where arg1, arg2… are the actual parameters. 

14. What are local variables?
Variables declared inside a block or function are said to belong only to that block and these are called as local variables. Values of these variables are valid only in that block.

15. What are global variables?
Variables declared before the main function block are called global variables. Values of these variables are available in every block of that program.

16. What is function prototype?
A function must be declared before it is actually called. The declaration of a function is known as function prototype. 

17. What is meant by scope of a variable?
1. The name of the variable.  2. The amount of space required to store that variable.  3. Address of the memory location. 4. The possible operations, which can be performed with the variable.

18. What are storage classes?
A storage class refers to the scope and life time of a variable i.e., the portion of program where the variable is valid and how long a variable can retain its value is defined in the storage class.

19. What are the different types of storage classes?
1. Automatic storage class 2. External storage class 3. Static storage class 4. Register storage class

20. does Register variable have address?
Ans: No. (CPU registers do not have addresses).