Computer for SEE and NEB

It is a complete SEE and NEB solution for computer science. It includes Computer Fundamentals, Database (SQL), Programming in C QBASIC, CSS, JavaScript, and PHP for beginners.

Breaking

Post Top Ad

Your Ad Spot

Sunday, March 6, 2022

QBASIC arguments in modular programming for class 10

QBASIC arguments in modular programming for class 10


QBASIC arguments in modular programming for class 10


What is modular programming?


QBASIC is a programming language that is widely used for developing small and medium-sized applications. It is one of the most popular languages used in the field of computer science and programming. One of the important features of QBASIC is the use of arguments in modular programming. Arguments in modular programming provide a way to pass data from one module to another module within a program. In this essay, we will discuss QBASIC arguments in modular programming for class 10 and their importance in programming.


What are the arguments in modular programming?


The consonant and variable enclosed in parenthesis of procedure call statement and that are supplied to a procedure are known as arguments. It is also known as real or actual parameters. The arguments are used to pass the values to the procedure.

 


How to pass arguments in QBASIC



To pass arguments to a procedure in QBASIC, you simply list them inside the parentheses of the CALL statement. The arguments are separated by commas. For example, the following code calls the add procedure and passes it the two arguments 10 and 20:


SUB add(a AS INTEGER, b AS INTEGER)

PRINT a + b
END SUB

CALL add(10, 20)

When the add procedure is called, the values 10 and 20 are assigned to the parameters a and b respectively. The add procedure then adds the two values together and prints the result to the screen.


Why use arguments in modular programming?


  • Flexibility: Using arguments, you can pass different values to a procedure each time it is called. This increases the procedure's flexibility and reusability.
  • Encapsulation: Arguments allow you to hide a procedure's internal implementation from the calling module. This strengthens the process and makes it easier to maintain.
  • Efficiency: Passing arguments by value can enhance program performance by minimizing the number of memory copies required.

Example: 1

 

Note: In above program, constant values are sent to the sub module.

 

Example: 2

 



Example: 3

Program for without declaring parameters and without passing arguments.

DECLARE SUB sum ()
CLS
CALL sum
END

SUB sum
INPUT "Enter any two number ="; a, b
s = a + b
PRINT "Sum="; s
END SUB

Note: In above example parameters are not declare and argument also not passing.

 

Example: 4

Passing Array argument to sub procedure

WAP to input any five numbers and display them in reverse order.

DECLARE SUB number (n())
CLS
DIM n(5)
FOR x = 1 TO 5
INPUT "Enter number="; n(x)
NEXT
CALL number(n())
END

SUB number (n())
FOR x = 5 TO 1STEP -1
PRINT n(x)

NEXT
END SUB
 


Note: In above program, the user input 5 different numbers in an array variable n(x) and passes it to the sub procedure. The sub procedure displays them in reverse order as output.


Conclusion:

In conclusion, QBASIC arguments in modular programming play a crucial role in developing programs that are modular, easy to maintain, and reusable. The use of arguments allows programmers to pass data between modules and make functions and subroutines more generic. The ability to use positional and named arguments, as well as default arguments, provides programmers with flexibility in designing and implementing their programs. It is important for any student of computer science and programming to have a thorough understanding of QBASIC arguments in modular programming for class 10 as it is a fundamental concept in programming.


You can also Read:


No comments:

Post a Comment

Post Top Ad

Your Ad Spot

Pages