Modular Programming (Theory Question)

 

1. What is modular program?

The modular program is a technique in which a program divided into small logical, manageable and functional part.

2. What is module?

The small, logical and functional part of a program is known as module.

Types of module:

i. Main module

ii. Sub- module

i. Main module: Modular Programming structure consists of many modules, the program entry point is a module, which is located at the top of the order modules. This top level module is called main module. The main module is the controlling section of a modular programming.

ii. Sub- module: Sub- module is a program which is written under the main module. A modular program may have one or more than one sub- module. It is called sub- program.

3. What is module level code and procedure level code?

The statement or codes written in a main module are called module level code. The statements or codes written in a procedure are known as procedure level code.

4. List some advantage of modular program.

a. The same procedure can be use more than one without rewriting it. so, it reduces the length of the program.

b. The debugging of the program become easier and faster.

c. The procedure can be tested and debugged separately.

d. It improves readability of a program.

5.       What is procedure?

A procedure is a block of statement that solves a particular problem given by user.

6.       Define Sub procedure.

A sub procedure is a small manageable and functional part of a program that performs specific tasks and does not return any value to the calling module.

7. Differentiate between sub procedure and function procedure.

Sub Procedure

a. Sub Procedure does not return value to the calling module.

b. A sub procedure name can’t be used an expression.

c. Sub procedure is called using CALL statement.

Function Procedure

a. Function Procedure value to the calling module.

b. A function name can be used in an expression.

c. Function procedure can be called by statement method using print statement or expression.

Point to remember:

·         Sub procedure does not return any value.

·         Sub procedure name can’t have type declaration sign.

·         Sub procedure name can’t be used as a variable.

·         Sub procedure can’t be used in an expression.

·         EXIT SUB statement can be used to exit from a sub procedure.

8. What is loop?

A loop is a structure which allows you to repeat a set of statement to a specified number of time or till the condition is satisfied. The loop inside a loop structure is known as nested loop.

Types of LOOP

i. FOR _ _ _ NEXT LOOP

ii. WHILE _ _ _ WEND LOOP

iii. DO _ _ _ WHILE LOOP

9.       What is function?

A function is a small ready made program which helps you to perform a task quickly and easily.

10.   What is user define function?

The function which is created by a user to perform specific task in a program is known as user define function. It is also known as custom function.

11.   What is library function?

The library function or built in function is ready made function provided by QBASIC. SQR (), INT (), LEFT$ () etc are eg. of library function

12.   What is Argument and Parameter?

The variable enclosed in the parentheses of the procedure which accept constant or variable passed to them from the calling module are known as Parameters. The parameters are also kwon as Formal Parameter.

The constants or variables enclosed in the parentheses of the calling statement are known as Argument. The argument is also known as Actual Parameter.

SUB CHECK (X, Y, Z)                         CALL CHECK (A, B, 20)

 

Procedure Name   Parameter            Procedure Name          Argument

 -----------------------------------------------------------------------------------------------

 FUNCTION CHECK (X, Y, Z)              A$= CHECK (A, B, 20)

 

Procedure Name     Parameter        Procedure Name      Argument

13.   What is Local variable and Global variables?

A variable which is define in a module and is not accessible to any other module is known as local variable. The Local variable is accessible to the module where it is define.

A variable in main module which can be access from any procedure of a program is known as Global variable. The global variable does not need to pass as argument to use in any procedure. A global variable is declared in the main module by using DIM or COMMON statement along with SHARED attribute. eg.   DIM SHARED a, b, c

            COMMON SHARED a, b, c    

14.   Write About SHARED, DIM SHARED, COMMON SHARED

SHARED

The Shared statement is used to share variables among parts of a module without making the variables global. It appears only in the sub module

eg SHARED a, b

DIM SHARED

The DIM SHARED statement makes the variable accessible or global to all the modules. It is used in the main module. eg DIM SHARED a, b

COMMON SHARED

The common shared statement is a non executable statement that declares variables as global, so that they can be shared between main module and sub module. eg COMMON SHARED a, b

CALL Statement: It is used to call or execute a sub procedure from the main module.

15.   Why QBASIC is called modular programming language?

QBasic is called modular programming language because it allows the user to divide program into manageable and functional modules or block with the help of sub procedure and function procedure.

 

 

Write the functions of:

1. LEFT$:

LEFT$ is a string function that allows us to extract the specific number of characters beginning from the left-most character of the string.

2. RIGHT$:

RIGHT$ is a string function that allows us to extract the specific number o characters beginning from the right-most character of the string.

3. MID$:

MID$ function returns a specific number of characters from a string.

4. LEN:

LEN function returns the number of characters in a string or the number of bytes required by a variable.

5. LCASE$:

LCASE$ function converts all the uppercase characters in lowercase.

6. UCASE$:

UCASE$ function converts string to uppercase.

7. ASC:

ASC function converts a character or a string variable to its corresponding ASC II code. Only the first character of a string is evaluated by ASC function.

8. CHR$:

CHR$ function retrieves the single character represented by the ASC II number.

9. STR$:

STR$ function converts a string expression to its string representation.

10. VAL:

VAL function converts a string expression consisting of digits into numeric value.

11. LTRIM$:

LTRIM$ function removes leading blanks from the left side of the spring expression.               

 

12. RTRIM$:

RTRI$ function removes trailing blanks from the right side of the string expression.

13. STRING$:

STRING$ function is used with a PRINT statement to display a particular character a specific number of times.

14. INSTR:

INSTR function returns the position of the first occurrence of a string in another string.

15. DATE$:

DATE$ function returns the current system date of the computer and allow to set the current system date.

16. TIME$:

TIME$ function returns the current system time of computer and allows to set the current time.

17. INKEY$:

 INKEY$ function checks the keyboard looking for a pressed key.

18. INPUT$:

INPUT$ function halts execution until a specified number of characters are read from the keyboard or a disk file.

19. ABS:

ABS function is used to obtain the absolute value of a numeric expression.

20. COS:

COS function computes the cosign of an angle.

21. TAN:

TAN function is used to obtain the tangent of x.

22. SIN:

SIN function is used to obtain the sine o an angle.

 

23. INT:

INT function is used to round the number to the integer value.

24. CINT: CINT function returns the nearest to the given number.

25. SGN: SGN function returns the sign of a number.

26. SQR:

SQR function returns the square root of a number.

27. TAB:

TAB function moves the text cursor to the specified print position.

28. SPC:

The SPC function skips a number of spaces when used with the PRINT and the LPRINT statement.

29. SPACE$:

The SPACE$ function is used to print a specific number of blank spaces.

30. LOCATE:

The LOCATE statement controls the cursor, placing it on the specific row and column on the screen.

 

 

16.   What is file handling?

File handling is a process to create a data file, write data to the data file and read data from the specific data file.

17.   What is file?

The collection of different data or information or instructions, which is stored in secondary storage devices under a unique file name, is known as file.

18.   What is program file and data file?

Data file is a collection of data such as name, address, phone, etc. required for data processing

The set of instruction written in a computer language for data processing under unique file is known as program file.

19.   List some advantage of data file.

Some advantages of data file are:

a.       The data stored in data file can be reused.

b.       It helps to store output for the future use.

c.       Data file can be created, modified or deleted.

20.   What do you mean by file mode? Write the difference mode of files in QBASIC.

The purpose of opening data file is called file mode.

The different modes of opening sequential data file are:

  1. Output or "O": To create a new sequential data file and write data in it.
  2. Input or "I": To read/display data or information from the existing sequential data file.
  3. Append or "A": To add more record in the existing sequential file. It starts adding of data always from the end of the file (EOF).

 

 

Comments

Post a Comment

Popular posts from this blog

DBMS (Ms-Access 2007 or above)

Computer Network and Telecommunication chapter 1