User defined functions

Jan 11 • Resources • 11112 Views • 23 Comments on User defined functions

Ques 1. What is the difference between user defined function and library function?
Answer. User Defined Functions has to be Developed by the user at the time of writing a program like Main() while library defined functions are already defined in the library of C and cannot be further modified like Printf().

Ques 2. What are the advantages of user-defined function?
Answer. Following are the advantages of user-defined function:-
1. It Facilitates top down programming.
2. It can be used by any other program.
3. Length of program can be reduced and makes debugging easier.

Ques 3. What are the elements of user-defined function?
Answer. There are three elements of user-defined function. These elements are as follows:-
1. FUNCTION DEFINITION
2. FUNCTION CALL
3. FUNCTION DECLARATION

Ques 4. What are the elements of function definition?
Answer. Function Definition shall include the following elements:-

function definition

Elements of Function Definition

1. FUNCTION NAME
2. FUNCTION TYPE.
3. LIST OF PARAMETERS
4. LOCAL VARIABLE DECLARATION
5. FUNCTION STATEMENT
6. RETURN STATEMENT.

Ques 5. What are the similarities between variables and functions?
Answer. They both have the following similarities:-
1. They both adhere to the rule of Identifier.
2. Both have a type associated with it.
3. Their type must be declared and defined before they are used.

Ques 6. What are the different categories of a function?
Answer. The different categories of a function are:-
1. FUNCTION WITH NO ARGUMENT AND NO RETURN VALUE.
2. FUNCTION WITH ARGUMENT AND NO RETURN VALUE.
3. FUNCTION WITH ARGUMENT AND ONE RETURN VALUE.
4. FUNCTION WITH NO ARGUMENT BUT RETURN A VALUE.
5. FUNCTION THAT RETURN MULTIPLE VALUE.

Ques 7. What are the rules for passing an array to a function?
Answer. There are three different rules for passing an array to a function:-
1. The function must be called by passing the name of an array.
2. In function definition the size of the array does not need to be specified.
3. The function prototype must show that the argument is in array.

Ques 8. What is the difference between Automatic variable and static variable?
Answer. Automatic variables are created when an already existing function is called and destroyed automatically while the Static variable can be declared anywhere in the program by using static keyword.

Ques 9. What are the different ways of parameter passing?
Answer. There are two different ways of passing data from one function to another:-
1. Pass by Value:-Actual parameter are copied to the variable in the parameter list of the called function.
2. Pass by Reference:-Memory address of the variable are sent to the called function.

Ques 10. What is the difference between global prototype and local prototype?
Answer. When we place the declaration above all the function it is called global prototype while when the prototype is in the function definition it is called local prototype.

If you like to download the questions and answers on User Defined Functions in pdf, then click hereĀ QUESTIONS ON USER DEFINED FUNCTIONS.pdf

Related Links-
Format Function: Basic Concepts
Functions in C Language

Tell us Your Queries, Suggestions and Feedback

Your email address will not be published.

« »