November 21, 2024

Control Statement and library function of QBASIC.

(i) User define function :> A user defines function is the function that is written or stored by the programmer to do a specific, task function. End Function Statement can be used to define user-defined functions.

(ii) Library function or Built-in function:-> function provided by the QBASIC System some common built-in functions are LEFT$, RIGHT$, LEN, etc.

*REM(Rapid Eye Movement): REM command is used to make any sentence is written in the program a message. syntax: REM

*DIM(Declare Into Memory): DIM command is used to declare a variable with its data type. syntax: DIM N as integer

*INPUT: Input Command is used to input some data of value from the Keyboard.Syntex Input “message”, eg: INPUT “ENTER YOUR NAME”, etc

*LEFT$: It extracts a Specific number of characters beginning from the leftmost character of the string. Syntax: LEFT$ (string, Exp,n)

*RIGHT$: It extracts the specified number of characters beginning from the Rightmost character of the string. Syntasc RIGHT$ (String, Exp,n)

* LEN(Load Equivalency Number): It returns a number of characters in a string. syntax = LEN (string. Exp)

* LCASE :> converts all the upper case characters to lower case.

* UCASE :> Converts stying into Upper case. 2, 3, 5, 8, 13 up to 10th term.

CIS A=2 B = 3 from i =2 to 10 print A, c = A+B A=B ,B=C NEXT i END

*MID$(Multifunctional Information Distribution System): It extracts the specified number of characters from a stying: Syntax: MID$ (Stxing Exp. start, length).

CIS X$ = “NEPAL for I: 1 to 10 LEN (X $) print TAB (I),MID$ (X$, I, I). NEXT, I END

* TAB:>TAB function move the text Cursor to the specific print position:

* MOD:->Divides the left operand by right operands & returns the (remainder).

*N E P A L

1. CLS X$ = “NEPAL” for i = 1 to LEN (X$) to step-1 print MID$ (X$, i, i) NEXT i ΕND

2. NEPAL NEPA NEP NE N solution, CLS X$ =”NEPAL” FOR, I= LEN to 1 (X$) to 1 STEP-1 print I ,LEFTS (X$, I, J) NEXT I ΕND

*DATA TYPE: Data Type is that which is used to declare the type of variable. The various types of dataType are:

*Variable: Variable is an area in the computer memory & within a program that can be referred by a name & whose value can be altered during the program execution. the rule for naming the variable is as follows :

(i) The variable can be a-z, A-Z alphabet.

(ii) The variable can be a maximum of 40 characters.

(iii) It doesn’t take the blank space.

(iv) QBASIC keywords and commands cannot be made the variable names.

Example: A$= “KTM”

x=10

*Types of variables:

(i) Numeric variable: Example : A=75, COM=7500 price = A to COM

(ii) String variable: It consists of letters & digits. It should start with a letter & end with ($) a string or dollar sign. It does not allow blank space. Its length may extend up to 40 characters & the string length can be from 0 to 255 characters.Example: A$=” POKHARA”

(iii) Constant: A symbol whose value does not change during the program execution is called constant.

Example:70,75,-21, 95, etc are the numeric constant among those with decimal are called numeric real constant. (70.75,20-50) whereas (95,-21) is called numeric integer constant.

Variable Declaration ( Implicit & Explicit declaration ):

(i) Explicit Declaration: The declaration of a variable before you use it or before assigning data to a variable is called an Explicit variable. The DIM statement is one most powerful statements for declaring explicit variables. The general format is the DIM variable as type ( as type define the type of variable integer, long integer, string )

DIM publisher A$ string

publisher = ”NEPAL”

The variable ”publisher ” is declared as a string variable & ” NEPAL” is stored in the string variable.

(ii) Implicit Declaration: The declaration of a variable at the place of assigning the value to a variable is called Implicit declaration.

(iii) wap to display the following numbers.

CLS

FOR i = 1 TO 5

FOR j = 1 TO i

PRINT j;

NEXT j

PRINT

NEXT i

END

*OUTPUT ANSWER :

Leave a Reply

Your email address will not be published. Required fields are marked *