Thursday, September 28, 2023

QBASIC (Theory)

 1.Modular programming

Modular programming is a technique used to divide program into many small, manageable, logical and functional modules or blocks.

2. Qbasic is called Modular Programming

QBasic is called modular programming because it divides program into many small, manageable, logical and functional modules or blocks.

3. Advantages of modular programming

i) Different programmers can design in different program modules independently.

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. Main module

The top level controlling section or the entry point in modular programming is called main module.

5. Sub module

Sub module is a block of statement that solves a particular problem. it is a program which is written under the main module.

6. Procedure

Procedure is a block of statements that solves a particular program which performs one or more specific tasks and can be accessed from remote location.

7. SUB procedure

A SUB procedure is a small, logical and manageable functional part of program which prefers specific task and does not return any value.

8. FUNCTION procedure

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.

9. String function :String function is used with string it returns string value.

10. Numeric function :Numeric function is used with number it returns numeric value.

11. Library functions

 Library functions are built-in or readymade functions provided by QBASIC. E.g. MID$( ), LEN( ), SQR( ) etc.

12. User defined function

Function which is defined by the user according to the need is called user defined function.

13. Parameters

Parameters are variables that will receive data (arguments value) sent to the procedures (SUB program and FUNCTION). Formal parameters are called parameter.

14. Arguments

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

15. CALL statement

The function of CALL statement is to transfer the control to another procedure.

16. DECLARE statement

The function of DECLARE statement is to declare procedure such as FUNCTION or SUB in modular programming.

17. DIM SHARED statement

 i) It makes variable accessible to all modules.

 ii) It appears in main module/ program.

18. SHARED

 It is used in the sub program to share the values of certain variables between main module and sub program

 19. COMMON SHARED

It is used in the main program to share variable list between main module and all sub programs. This statement is used to declared variable global.

20. Local Variable

Variables which are declared inside the procedure are called local variables which are not visible to other modules or functions and can access only in its own module.

21. Global Variable

Variables which are declared outside the procedure are called global variables which are visible to other modules or functions. Its values can be accessed from any procedure or module.

22. Static variable

The variable which is declared by using the “STATIC” keyword is called static variable.

Handling of data file Questions and Answers

1. Data file

The file which contains data given by the user to the program and information provided by the user to the computer is called data file.

The different types of data file are:

a) Sequential Access files

 A data file that stores a sequential data file containing name, address of some people in the same order or in sequential order which takes long time to access from large volume of data.

b) Random access files

A data file that stores a sequential  data file randomly using large array or indexing method and can be retrieved or accessed and rewritten quickly from anywhere.

2. Program File

The file which contains a set of instructions that are needed for data processing is called program file.

3. Mode of data file

Mode of data file means opening a sequential file for one of the three modes of operation like output mode, input mode and append mode.

4. Modes of operation for opening a sequential file

a) Output Mode:

 It is used to create a new data file and write data in it. If the file already exists its current contents will be destroyed.

b) Input Mode: It is used to retrieve records or contents of existing data file.

c) Append Mode: It is used to add more records in existing file. If the specified file does not exist APPEND mode creates it.

5. File number

The number assigned to a file in order to identify it during processing is called file number.

Write down the functions of:

6. OPEN statement:

It opens a sequential file for one of the three possible operations (reading, writing, appending).

7. WRITE statement

It sends one or more data items to the specified file. It inserts commas between the data items. It encloses strings in double quotation marks.

8. PRINT#:

It adds spaces between data items while storing data. It does not enclose strings in double quotation marks.

9. CLOSE statement :It closes one or all open files.

10. INPUT# statement :It reads data from the sequential data file.

11. EOF( ) function :It is used to test the end of records with in a file.

12. LINE INPUT statement:

 It reads the entire line or maximum 255 characters form the keyboard or the sequential file.

13. INPUT$ function:

It reads the specified number of characters form the data file.

14. NAME statement

The NAME statement renames a file on a diskette. Only file name changes, data and program line remains intact.

15. KILL statement

The KILL statement deletes the file or files from the specified drive and directory.

16. MKDIR statement :It creates a sub directory which is used to manage files.

17. CHDIR statement:  It allows QBASIC to change from one directory to another.

18. RMDIR statement

It is used to remove or delete only the subdirectories from a disk. It can remove only empty subdirectories.

19. FILES statement:

The FILES statement displays the files of the current sub directory or specified sub directory.

20. SHELL:

The SHELL statement allows a program to run external programs or command line statements in Windows, MAC OS and Linux.

21. INT

It rounds and returns the largest integer less than or equal to a numeric expression.

22. PRINT

 Display result on screen.

23. MID$ ( )

It is a string function that returns the specified number of characters from the specified location of string.

24. LEN ( )

Returns the number of characters in a string or the number of bytes required to store a variable.

25. SQR ( )

Returns the square root of a numeric expression.

0 comments:

Post a Comment