If you cannot find what you are looking for. Please visit our sitemap

ICS Notes Computer Science Part 2 Chapter 13 Functions in C Short Questions

ICS Notes Computer Science Part 2 Chapter 13 Functions in C Short Questions

Q 1. What is modular programming?
Ans. A programming technique in which a program consists of many independent parts is called modular programming. These parts are called modules. These parts are also called function. Each module can perform different tasks. The development speed of a program increases as different programmers can write different modules of a program. Different modules are combined to make a complete program.

Q 2. What is a function?
Ans. In structured programming the program consists of more than more one part. Each part of program is called a module or function. Every function is given a unique name and it is developed to perform a specific task. So function can be defined as " A named piece of code developed to perform a specific task is called function".

Q 3. Why functions are used?
Ans. Function is a piece of code designed to perform a specific task. There are many advantages of using functions. These advantages are described below:

  • Easy programming
  • Easy modification
  • Easy debugging
  • Reuse-ability
  • Eliminates duplicate code
  • Less programming time

Q 4. What are built-in functions?
Ans. The function that are provided as a part of C language are called built-in functions. These functions are also called library function. A large number of built-in functions are provided by C language. These functions are stored in different header files. If we want to use a built-in function in a program the relevant header files is included at the start of the program in Preprocessor directive.

Q 5. What are user defined functions?
Ans. The functions that are written by the programmer to perform specific task are called user defined functions. These functions are written according to the requirement of the program.

Q 6. What is function prototypes?
Ans. Function declaration is also called function prototype. It is a statement that provides basic information to compiler about the structure of the function like other C language statement, function declaration statement also ends with semicolon. Function declaration is necessary like variable declaration. A function must be declared in a C language program. Function can be declared before the main() function or inside the main() function.

Q 7. What is function definition?
Ans. Every function perform some specific task. The task is performed when the set of instructions execute. Writing set of statements of a function is called function definition. Function definition is always done outside main() function.

Q 8. What is function header?
Ans. The first line of the function definition is called function header. Its general syntax is as follow:

  • Return-Type Name(parameters)

Q 9. What is function calling?
Ans. The statement that is written to use a function is called function call. A function can be called at any point in the program. A function is called by using its name. The required parameters are maintained after the name in braces at the end of the function call statement. Semicolon is used at the end of statement in which function is called.

Q 10. What is return statement?
Ans.  Keyword "return" is used to return a value from the body of called function to calling function. The statement in which "return" keyword is used is called return statement. The general syntax for return statement is as follow:
return expression;

Q 11. What are parameters?
Ans. Parameters are also called arguments. These are the values that are provided to a function when it is called. when function is called parameters are written after function name in parenthesis. These parameters can be variables or constants. More than one parameter is separated by comma.

Q 12. What is a local variable?
Ans. The variables declared inside main() function, inside any user defined function or header of function definition are called local variables. Local variable also called automatic variables. The general syntax to declare a local variable is as follows:
auto data-type variables-name;

Q 13. What is global variable?
Ans. The variables that are declared outside the main() function or any other function are called global variable. Global variables are also called external variables. Global variables can be used by all functions in the program. All functions can share their value. If value of a global variable is changes in a function, that changes value is also available in other functions.

Q 14. What is meant by life time of a variable?
Ans. Lifetime of a local variable is limited, when control enters into the function and variable declaration statement is executed, they are created in memory. When the control exits from the function these variables are destroyed and their life ends, when variables are destroyed the data stored in them also becomes inaccessible.

Q 15. What is meant by scope of a variable?
Ans. Local variables have a limited scope they can only be used in the function in which they are declared. Compiler generates an error if we want to access a local variable, outside its scope.

Q 16. What is scope of global variable?
Ans. Global variables can be accessed in all modules of program. They are accessible in main() function as well as all other user defined functions.

Q 17. What is life time of global variable?
Ans. When program starts execution, global variables are created in memory. They remain in memory till the termination of the program. When the program is terminated global variables are destroyed from the memory. Therefore life time of a global variable is between starting and termination of program.

Written by: Asad Hussain  &  Sana Hussain