Monday 24 November 2014

Modular Programming

Modular Programming


1)     What is a modular programming?Ans: Modular programming is a technique used to divide program into many small, manageable, logical and functional modules or blocks.
2)     What is module?Ans: Module is a block of statement that solves a particular problem.
3)     What are the advantages of modular programming?Ans: The advantages of modular programming are:
i) Different programmers can design different program modules independently, which is required in a large and complex program.
ii) It is easy to design code and test the program modules independently.
iii) It is possible to use a single module in different places which reduces program codes.

4)     What are two procedures QBASIC support to divide programs?Ans: The two procedures used to divide programs in QBASIC are SUB-procedure and FUNCTION-procedure.
5)     What is SUB-procedure?Ans: A SUB-procedure is a small, logical and manageable functional part of program which prefers specific task and does not return any value.
6)     What is a FUNCTION-procedure?Ans: A FUNCTION-procedure is a small, logical and manageable functional part of a program which performs specific task and returns single value to the main program or calling module.
7)     Write down the function of CALL statement.Ans: The function of CALL statement is to transfer the control to another procedure.
8)     Write down the function of DECLARE statement.Ans: The function of DECLARE statement is to declare procedure such as FUNCTION or SUB in modular programming.
9)     What is main module?Ans: The top level controlling section or the entry point in modular programming is called main module.
10) What is sub module?Ans: Sub module is a program which is written under the main module. A program may have one or more sub modules under main module.
11) Define parameters and arguments.Ans: Parameters are variables that will receive data (arguments value) sent to the procedures (SUB program and FUNCTION).

Arguments are the values that are sent to the procedures (SUB program and FUNCTION)
* Actual or real parameters are called arguments.
* Formal parameters are called parameter

12) What is actual parameter?
Ans: The parameter passed to the procedure from the calling procedure statements are called actual parameters.

13) What is formal parameter?
Ans: The parameter in the procedure which receives the value from the actual parameters are called formal parameters.

14) Write down the functions of DIM SHARED statement.Ans: The functions of DIM SHARED statement are:
i) It makes variable accessible to all modules.
ii) It appears in main module/ program.

15) What are library functions?Ans: Library functions are built-in or readymade functions provided by QBASIC.
16) What is user defined function?Ans: Function which is defined by the user according to the need is called user defined function.
17) Write down the differences between SUB and FUNCTION procedure.Ans:
SUB-procedure
FUNCTION-procedure
i) SUB-procedure does not return value.
i) FUNCTION-procedure must return a value.
ii) SUB-procedure is called by CALL statement.
ii) FUNCTION-procedure is called by statement and expression method.
iii) SUB-procedure’s name does not accept data type symbol because it does not need to return a value.
iii) FUNCTION-procedure’s name accepts data type symbols such as $, %, !, #, &, etc. and it depends on the type of value to be returned. E.g.: FUNCTION REV$ returns string.

18) Differentiate between SHARED and COMMON SHARED.Ans:
SHARED
COMMON SHARED
It is used in the sub program to share the values of certain variables between main module and sub program
It is used in the main program to share variable list between main module and all sub programs.

19) Differentiate between local variable and global variable.Ans:
Local Variable
Global Variable
i) Variables which are declared inside the procedure are called local variables.
i) Variables which are declared outside the procedure are called global variables.
ii) Local variables are not visible to other modules or functions.
ii) Global variables are visible to other modules or functions.
iii) Its value is protected from outside interference and has no effect on the variables outside the procedures.
iii) Its values can be accessed from any procedure or module.


20) Differentiate between passing argument by value and passing argument by referenceAns:
Passing arguments by value
Passing arguments by reference
i) When arguments are passed by value it makes a duplicate copy of arguments and their values (constants) are used directly in parameter.
i) When arguments are passed by reference the address of the variables are passed to the procedure.
ii) It doesn’t make any effect on values of variable which are passed to a procedure even they are changed in the procedure.
ii) The changes made in the procedure’s variable will affect the variables used at calling module.
iii) To pass the argument by value, variable is enclosed in parenthesis.
iii) By default the value is passed by reference.


21) Why is large modules broken into small procedures?
Ans: Large modules are broken into small procedures to eliminate redundancy, for easier understanding, testing and debugging.

22) What are the major features of SUB procedure?
Ans: The major features of sub procedure are:
       i.          It does not return any value.
     ii.          It does not have a data type.
   iii.          The parameter can be passed by reference or by value.
   iv.          They can be recursive.

23) What are the three important parts of SUB procedure? List with examples.
Ans: The three important parts of SUB procedure are:
       i.          Declaration of SUB procedure
Example: DECLARE SUB AREA (L, B)
     ii.          Body of SUB procedure
Example: SUB AREA (L, B)
                                        .
                                        .
                                        .
                                        END SUB
   iii.          Invocation of SUB procedure
Example: CALL AREA (L, B)


24) What is static variable?
Ans: The variable which is declared by using the “STATIC” keyword is called static variable.

25) What is automatic variable?
Ans: An automatic variable is a local variable which is allocated and de-allocated automatically when program flow enters and leaves the variable's scope. 

26) What is an array?
Ans: An array is a collection of multiple data elements stored under a common variable name.

27) What is recursion?
Ans: Recursion is a programming technique that allows the programmer to express operations in terms of themselves.

No comments:

Post a Comment

MCQ Question Bank Microsoft PowerPoint