Functions Class 12 Computer Science Important Questions

Important Questions Class 12

Please refer to Functions Class 12 Computer Science Important Questions with solutions provided below. These questions and answers have been provided for Class 12 Computer science based on the latest syllabus and examination guidelines issued by CBSE, NCERT, and KVS. Students should learn these problem solutions as it will help them to gain more marks in examinations. We have provided Important Questions for Class 12 Computer Science for all chapters in your book. These Board exam questions have been designed by expert teachers of Standard 12.

Class 12 Computer Science Important Questions Functions

Short Answer Type Questions:

Question: Distinguish between arguments and parameters?
Ans: These are variables used in function. These are the optional part of the function. Their existence depends on the requirement of the user. It means there may be zero or more arguments. These arguments are of two types:
Arguments: Variables used in a function call are called arguments. These are written within the parentheses ( ) after the function name in the function call. They are also called actual parameters.
Parameters: Variables used in the function definition are called parameters. They are also called formal parameters. They receive values form the calling function. Parameters must be written within the parentheses ( ) after the function name in function definition.

Functions Class 12 Computer Science Important Questions

Question: When will the execution of the function terminates?
Ans: Function is the logical grouping of statements. Functions are used to solve a complex problem by dividing it into smaller parts. A function once defined can be used many times. When a function is called, it starts its execution. This execution goes on till the end of the body of the function. When function completes its execution, program control is returned to the calling function.

Question: Explain the advantages or uses of function?
Ans: Using functions have a number of advantages. The main advantages of using a function are:
It becomes easy to solve a complex program by dividing it into small functions.
It becomes easy to debug the program.
It is easy to maintain and modify a function.
It allows the reusability of code. A function can be called any number of times but defined only once.
Small functions are self-documenting.
It allows the programmer to build a library of the commonly used functions.
It facilitates top-down modular programming approach.

Question: What is the need of function declaration?
Ans: Function declaration is also called Function Protoyping. It is different from function definition. It does npot have any body. It is terminated with semicolon (;). Function declaration provides the information to the compiler about the type of function, its name and arguments. When we call a function to use it, compiler verifies the function call with its declaration. If function declaration does not found, compiler will display an error message.

Question: How does a function definition differ from function declaration?
Ans: Function declaration is also called Function Protoyping. It is different from function definition. It does npot have any body. It is terminated with semicolon (;). Function declaration provides the information to the compiler about the type of function, its name and arguments. When we call a function to use it, compiler verifies the function call with its declaration. If function declaration does not found, compiler will display an error message.
 Function Definition defines the working of the function. In the definition of a function, we define the type, name, arguments and body of the function.

Question: What role does the return statement play?
Ans: Rerurn is a keyword. It is used in the definition of functions. This keyword is used in those functions which return a value to their calling function. Return statement must be the last statement in the body of the function.
For example:
    int sum(int a, int b)
   {
    int c=a+b;
    return c;
    }
In the above example, the function sum() returns the value of c to its calling functions with the help of return statement.

Question: What are User Defined Functions?
Ans: Those functions, which are defined by the user, are called user defined functions. User can define his own functions to fulfil his requirements. The function main() is an example of user defined function. Its body is defined by user.

Question: What are Storage Classes?
Ans: Storage classes are used to define the scope, life and location of a variable in the program. In C, four storage classes are used to define scope, life and location of variable. These are:
1. Automatic Variables
2. Register Variables
3. Static Variables
4. External Variables

Question: What are functions? Write their types.
Ans: A function is a subprogram. It is also called a Routine or Procedure. It is a logical grouping of statements in a program. Functions are used to solve a complex problem by dividing it into smaller parts. A function once defined can be used many times. In every executable programs, there must be a main() function in the program. Program execution starts from this main function. In other words, we can say that main function act as a entery point of execution on the program.
Types of Functions:
Functions can be classified mainly into two categories:
1. Library or Built-in functions
2. User defined functions

Functions Class 12 Computer Science Important Questions

Question: What are Library Functions?
Ans: Those functions, which are in-built or pre-defined in the C language, are called standard or library functions. All these functions are organized in header files (also called library files). To use any library function, we must include the corresponding header file (in which it is defined) in our program. For example: clrscr( ), printf(), scanf(), sqrt(), strcpy() etc. are the predefined functions. The input output functions scanf( ) and printf( ) are defined in the stdio.h header file. So, we have to include this file in our program if we want to use these functions. Similarly, string functions strlen( ), strcpy( ), strcat( ), strcmp( ), strupr( ), strlwr( ) etc. are defined in the string.h header file. So, we must include string.h header file to use these string functions in our program.

Functions Class 12 Computer Science Important Questions