Modular Programming in QBASIC

Filter Course


Modular Programming in QBASIC

Published by: BhumiRaj Timalsina

Published date: 10 Jan 2022

Modular Programming in QBASIC

Introduction

The process of breaking a large program into small manageable tasks and designed them independently is called modular programming. A module program consists of a main module and one or more sub modules or procedures.This note provides an information about modular program in QBASIC.

The process of breaking a large program into small manageable tasks and designed them independently is called modular programming. A module program consists of a main module and one or more sub modules or procedures. Each sub module has a unique name. Modular Programming is a approach in which the program is divided into separate independent units is called modules.

A modular program consist of main module and sub-module.

  1. 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 modular programming.
  2. 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. Qbasic is also known as modular programming language because it allows the user to divide program into manageable and functional modules or blocks with the help of sub procedure and function procedure.
  • It reduces the program code.
  • It is possible to use single module in different places.
  • It makes debugging easier.
  • It makes the maintenance of the program easier.
  • It reduces the chance of changing the value of the variable accidentally.

Procedures In Basic

There are two types of procedures in BASIC. They are as follows:

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. A sub program is written with SUB....END SUB statements.

Some important features of sub procedure are as follows:

  • It does not return any value.
  • Sub procedure name can't be used as variable.
  • Arguments can be passed to the sun program by reference or value.

Function Procedure : A function procedure is small manageable and functional part of a program that performs the specific tasks and returns a single value to the main program or calling module. A function is written with FUNCTION....... END FUNCTION statement.

Some important features of function procedure are as follows:

  • It returns a value.
  • Function procedure name has type declaration sign.
  • Arguments can be passed to the sub-program by reference or by value.

Arguments

The constant or variables enclosed in the parentheses of procedure call statement and that are supplied to the procedure are known as arguments. The argument can be passed to a procedure either by reference or by value method.

Formal and Actual Parameter: Formal parameters are used to specify or declare the type of data to be passed to the procedures either by sub or function procedure.

Parameters

Variables in sub procedure declaration which accept data or variables passed to them from the calling module are known as parameters. It is also known as formal parameter.

Local and Global variable : A variable which is defined in a module ans is not accessible to any other modules is known as local variable. A variable in main module which can be accessed from any module or procedure of a program is known as global variable.