Fundamental question from Modular Programming
1) What is user
defined function? (Specification Grid 2065, SLC supplementary 2066)
Ans: Function which is defined by the user according
to their need is called user defined function.
2) Write down the
difference between function and sub procedure. (SLC supplementary 2065)
Ans: The difference between function and sub
procedure are as follows:
Function |
Sub
procedure |
Function return a single value |
Sub procedure does not return a
value |
It can be called by expression or
PRINT statement or expression method. eg. b = abc (n) |
It is called by CALL statement. |
3) What is
procedure? List its types. (SLC 2067, SEE 2072)
Ans: A small, logical and manageable functional
part of the program is known as procedure. OR,
It is a collection of
code to perform an action which does not return a value. Its types are:
i) Sub
procedure
ii) Function procedure.
4) Define subroutine.
Ans: Subroutine is a set of program statements that
can be called from different places of the main program.
5) Write the features
of subroutine
Ans: The features of subroutine are as follows:
i) It is called by CALL
keyword.
ii) It does not return
any value.
iii) It does not
consider data type.
iv) It can be recursive.
6) What do you mean
by procedure?
Ans: Procedure is a collection of code to perform
an action which does not return a value. There are two types of procedures:
i) Sub procedures
ii) Function procedures
7) Write the
importance of subroutine.
Ans: When our program becomes bigger, its code
becomes more and more difficult to understand and difficult to find out the
bugs, then with the help of subroutine we can mare program simpler and easier.
8) What do you mean
by recursion?
Ans: A sub program or module that can call itself is
called recursion.
9) What is variable?
Ans: The entity of number or string whose value are
changeable during the program execution time is called variable.
10) Write the difference between local and
global variable.
Local
variable |
Global
variable |
The variable which declared inside
the procedures are called local variable. |
The variable,
which can be accessed from any procedure or module is called
global variable |
It is not accessible by other
functions. |
It is accessible by all the other
functions |
11) What
is a declare statement? Write its syntax.
Ans: It declares function or sub procedure and
invokes arguments data type checking.
Syntax:
DECLARE SUB/FUNCTION name (parameter list)
12) Distinguish between
shared and common shared.
Shared |
Common
shared |
It gives procedures access to
module level variable |
It
defines global variable that can be shared throughout a program or between
chained program. |
13) Define
Function….End function.
Ans: It is a non executable statement that declares
the name, the parameters and the code that form the body of a function
procedure.
14) Write the types
of function.
Ans: There are two types
of functions. They are as follows.
i) Library or built - in
– function
These function are
provided by Qbasic software. eg. sqr( ), int( ), left$( ), len( ), mid$( ),
date$( ) etc..
ii) User defined functions
Functions, which are
defined by the user according to the need are called user
defined function.
15) Write the
advantages of function.
Ans: Following are the
advantages of function.
i) There is no chance of
duplication.
ii) It can be developed,
tasted, debugged, and compiled independently.
iii) Each function is
reusable.
iv) Program can be
developed in short period of time.
v) Large numbers of
programmer can be involved.
16) In how many ways we can pass the arguments in
function and procedure?
Ans: We can pass the arguments in function and
procedure as follows:
i) By reference
ii) By value
iii) By enter
array into the function
17) What do you mean
by parameters?
Ans: Parameters are variable that will receive data
sent to the procedure. (Sub
procedure and
function)
OR
Parameters are the
pre-defined variable that indicates the input given to the sub-procedure.
18) Define arguments.
Ans: Arguments are the actual values, we pass to the
sub-procedure.
19) Difference
between actual parameters and formal parameters. (SEE 2074)
Ans: The difference between actual parameters and
formal parameters are as here under:
Actual
parameter |
Formal
parameter |
The parameters listed in a
function call are called the actual parameters. |
The parameters included in
function declarations are called formal parameters. |
20) What is loop? (SLC 2068, Supp 2070, SEE 2073)
Ans: Repetition of statements for number of times on
the basis of given condition is known as loop.
21) What is meant by
mode of data file? (SLC 2069)
Ans: Mode of data file means the file to be
opened in specific access mode such as reading and writing (Output, Append and
Output)
22) What is a
variable? (SLC 2070)
Ans: Variable is a location in the memory, contents
of which can be changed during the execution of program.
23) What is a
constant?
Ans: The entity (data or value) which cannot be
changed during the program execution is called constant.
24) What is an operator?
Ans: An operator is a symbol or sign used to
indicate a specific operation between the operands in a program.
25) Define statement.
Ans: A statement
is a set of instructions written using keywords or commands of
programming language.
26) Write
the difference between Argument and parameter.
Argument |
Parameter |
Arguments are values that are sent
to the procedure. |
These are variables that will
receive data sent to the procedure. |
27) 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.
28) Define logical
operators. (SEE 2075)
Ans: Logical operators are symbols, which are used to
combine two or more logical or relational expressions and return a single
‘true’ or ‘false’.
29) Write the difference
between library functions and user define functions
Library
Functions |
User
defined functions |
Library functions are built it or
predefined function of QBASIC |
User defined functions are defined
or declared by the user. |
These types of functions are
common for all the users. |
These types of function are
declared by individual user on the basis of requirement. |
Example: LEN, LEFT$,
DATE$ |
FUNCTION cube(a) |
No comments:
Post a Comment