4.7.2. QBASIC Statement
An assertion (for the QBASIC) is a bunch of directions composed by utilizing catchphrases or orders of QBASIC. Each programming language involves watchwords as an explanation with specific grammar. The watchwords have explicit importance in the QBASIC programming. The assertions are the principal put away in the memory and executed just when the RUN order is given.
The various sorts of assertions utilized in QBASIC are as per the following:
- Announcement articulation
- Task proclamation
- Input/yield proclamation
- Control proclamation
22.214.171.124 Declaration Statement
The explanations which are utilized to characterize and pronounce the qualities, factors, constants and so on for programming intention are known as announcement articulation. The announcement explanations are DIM, REM, CONST, DECLARE and so on.
A fundamental statement proclamation permits logical comments to be embedded in a program. The comments might be valuable in a program to make sense of about various types of proclamations and client characterized words. Adding remarks in the program permits us to remind about the program and furthermore assists different software engineers with grasping the rationale of the program.
Sentence structure: REM < Remarks>
The assertion pronounces at least one representative constants in program.
|Syntax CONST constantname = expression [,constantname =
|The name of the constant. This name can consist of up to 40
characters and must begin with a letter.
Valid characters are A-Z, 0-9, and period (.).
|An expression that is assigned to the constant can consist of
literals (such as 1.0), other constants, any arithmetic or logical operators
except exponentiation (^), or a single literal string.
Model CONST PI = 3.141593
Faint proclaims a cluster or determines an information type for a non exhibit variable.
Const pi = 3.14
Faint r as single
Faint an as single
r = 5
a= pi *r^2
PRINT “area of circle =”; a
[SHARED] variable [(subscripts)] [AS type] [, variable[(subscripts)] [AS
|Specifies that variables are shared with all
SUB or FUNCTION procedures in the
|The name of an array or variable.
|Dimensions of the array, expressed as
|[lower TO] upper [,[lower TO] upper]…
|The lower bound of the array’s subscripts. The default lower
bound is zero.
Declares the data type of the array or variable (INTEGER, LONG, SINGLE, DOUBLE, STRING, or
a user-defined data type).
126.96.36.199 Assignment Statement
The explanations which are utilized to appoint the worth to the connected variable are known as task articulations. The task proclamations are Let, Swap and so forth.
LET is a task proclamation. Doling out the worth to a variable is utilized. LET is a discretionary assertion for example without utilizing LET explanation one can dole out the worth to a variable. The information type should coordinate with the variable sort in any case type confound mistake will happen.
Sentence structure: |LET| variable = worth or articulation
INPUT ” First Number”; A
INPUT “Second Number”; B
LET S = A+B
PRINT ” The Sum is”; S
Peruse Data Statement
It is utilized related to the DATA order which lets QBASIC to understand information. It is utilized generally while managing enormous amounts of information in program.
Peruse A, B, C
PRINT A, B, C
188.8.131.52 Input/yield Statement
The explanations which are utilized to give contribution to factors of QBASIC program for handling and show the outcome as result on the screen are known as information/yield articulation. The info/yield explanations are : CLS, INPUT, LINE INPUT, PRINT, PRINT USING and so on.
The CLS explanation clears the screen. In the event that you compose CLS proclamation in the program, you can’t see the results created before execution of CLS since it clears the screen.
Language structure: CLS
It gets input from the console during the execution of the program. Punctuation: INPUT [“Message”] ; Variable
PRINT articulation gives yield on the screen. It prints the upsides of the articulation on the screen. Assuming the articulation list is clear, no characters are printed. The articulations in the rundown might numeric or string. In the event of number, the negative number is gone before by a less sign (- ) yet in sure number it is gone before by a space. We can utilize semicolon and comma with a print proclamation which results uniquely in contrast to an ordinary PRINT explanation. Assuming that articulation list closes with comma or semicolon, the following PRINT proclamation prints on a similar line. Comma gives a TAB space yet semicolon gives just a single space.
Linguistic structure: PRINT [“Message”]; articulation
PRINT “We live in Nepal.”
PRINT “Nepal in the middle among India and China.”
PRINT ” The number is: “; 7
We live in Nepal.
Nepal in the middle among India and China.
The number is: 7
This assertion permits contributing line of information at an at once in to single variable.
Punctuation: LINE INPUT “string”; string variable
LINE INPUT “if it’s not too much trouble, enter the information”; n$
184.108.40.206 Control Statement
The explanations which are utilized to move the control of program starting with one section then onto the next part regardless of condition are known as control articulations. The control explanations are IF THEN, SELECT CASE, FOR NEXT, DO LOOP, ON GOTO and so on.
The GOTO is a bouncing explanation which hops starting with one point then onto the next point inside program. Moving the control starting with one mark of the program then onto the next point without testing a condition is utilized. The GOTO proclamation is set apart by name explanation. It sends the controls to the marked block and starts executing.
Language structure: GOTO <label/line number>
Where mark is a name followed by a colon.
INPUT “ENTER YOUR AGE”; A
On the off chance that A>18, GOTO TEST1 ELSE GOTO TEST2
PRINT “YOU ARE ELIGIBLE FOR VOTE”
PRINT “YOU ARE NOT ELIGIBLE FOR VOTE”
On the off chance that – Statement
At the point when there is a solitary choice to be executed on the fundamental of genuine consequence of a condition, then ‘ in the event that – – end if ‘ proclamation utilized. In this way, there is a test for a condition in ‘on the off chance that -‘ proclamation and on the off chance that the consequence of the condition is viewed as ‘Valid’, the assertion of ‘In the event that’ block is executed and in the event that the aftereffect of the condition is FALSE, there is no assertion to execute. In such case, basically the program execution goes to the line underneath the END IF explanation. Thus, it performs when the condition is just TRUE.
In the event that [condition],
Block of articulations
Input”Enter your age”; a
In the event that a<=10,
In the event that, Else Statement
At the point when there is a need to choose a choice to be executed out of two choices based on two circumstances, the ‘in the event that – – else proclamation is utilized however the subsequent condition is rarely checked. In this way, there is a test for a condition in on the off chance that – – else ‘ proclamation and in the event that the consequence of the condition is viewed as obvious, the block of explanation related with ‘if’ part is executed in any case the block of explanation related with ‘Else” part is executed. There is no possibility to execute both in the event that and else part inside a solitary if – – else proclamation.
On the off chance that [condition],
Block 1 of explanations
Block 2 of articulations
INPUT “ENTER A NUMBER”; N
On the off chance that N MOD 2 = 0,
PRINT “Much NUMBER”
PRINT “ODD NUMBER”
On the off chance that, Elseif Statement
At the point when there is a need to choose a choice to be executed out of numerous choices based on different circumstances, the ‘in the event that – – elseif explanation is utilized. On the off chance that none of condition is valid, proclamation related with ‘else’ part is executed.
In the event that [condition1],
Block 1 of articulations
Elseif [condition2] then, at that point,
Block 2 of articulations
Elseif[condition3] then, at that point,
Block 3 of articulations
Block ‘n’ of articulations
REM POSITIVE, NEGATIVE OR NEUTRAL NUMBER
INPUT “ENTER A NUMBER”; N
In the event that N > 0,
PRINT “POSITIVE NUMBER”; N
ELSEIF N<0 THEN
PRINT “NEGATIVE NUMBER”; N
PRINT “Impartial NUMBER”; N
Select… Case… Explanation
Select case is additionally the various expanding proclamations. It is utilized to executed one of a few assertion blocks relying upon the worth of an articulation.
Select case test_expression
Case test 2
INPUT “ENTER AGE OF A PERSON”; A
SELECT CASE A
CASE 1 TO 12
CASE 13 TO 19
CASE 1 TO 12
CASE 20 TO 40
CASE 41 TO 70
FOR NEXT Statement
Rehashes a gathering of proclamations a predefined number of times.
For counter = begin To end [Step step]
The For…Next proclamation linguistic structure has these parts:
|Numeric variable used as a loop counter. The variable can’t be
an array element or an element of a user-defined type.
|Initial value of counter.
|Final value of counter.
|Amount counter is changed each time through the loop. If not
specified, step defaults to one.
|One or more statements between For and Next that are executed
the specified number of times.
The step contention can be either certain or negative. The worth of the step contention decides circle handling as follows:
When the circle starts and all assertions in the know have executed, step is added to counter. As of now, either the articulations in the know execute once more (in view of the very test that made the circle execute at first), or the circle is left and execution go on with the assertion following the Next explanation.
REM DISPLAY FROM 1 TO N NUMBER
INPUT ” ENTER THE VALUE OF N”; N
FOR I =1 TO N
Compose a program to show Fibonacci series 2,2,4,6,10,16,… , up to tenth terms.
FOR J=1 to 10
Compose a program to show the converse word for any entered word by a client.
INPUT “Enter any word”;n$
FOR j=LEN(n$) TO 1 STEP – 1
PRINT “The converse word is “;Rev$
Compose a program to find the best number among any 10 numbers entered by a client utilizing a cluster.
Choice BASE 1
PRINT “Enter any 10 number
- The strategy used to foster an answer or a program is called programming. It is approach to composing program utilizing explicit code to perform explicit errand.
- The arrangement of codes which is utilized to compose PC program is called script.
- The first program written in significant level language is called source program.
- The program changed over into machine code by compiler is called object program.
- The program composed utilizing machine code or parallel numbers (0 and 1) is called machine level language.
- The language which allows the utilization of memory aides (which are mix of codes and English expressions) for every guidance that machine can do is called low level language.
- The language which uses plain English words or expressions and numerical documentation, following the right sentence structure (Certain principles which are followed to compose programs) is called significant level language.
- Fourth-age PC programming language. 4GLs are nearer to human language than other undeniable level dialects and are open to individuals without formal preparation as developers.
- The arrangement of program codes, which are utilized to decipher program written in significant level language or low level language into machine code, is called language processor.
- The language processor which changes over High level language and Low level language into machine code is called translator.
- The language processor which deciphers the program written in undeniable level language into machine code is called compiler.
- The language processor which deciphers the program written in low level language into machine code is called constructing agent.
- Created by John George Kemeny and Thomas Eugene Kurtz at Dartmouth in 1964, it is an abbreviation for Beginner’s All-reason Symbolic Instruction Code. It was planned with the goal of giving the non-science individuals an admittance to PCs. PHP is one of the prevalently utilized universally useful prearranging dialects. It is produced for making dynamic pages and supports an order line interface capacity.
- Programming are comprised of at least two than two projects.
- Programming are comprised of at least two than two projects.
- A PC program is an assortment of directions that plays out a particular undertaking when executed by a PC.
- The designs which manage the request where program proclamations are executed are called Control Structures. There are 3 sorts of control structure.
- Program Design instruments are the instruments used to foster a program. During planning a program, various devices are expected to take care of a few issues.
- A calculation is a grouping of guidelines or bit by bit guidance to track down the arrangement of an issue.
- A flowchart is a pictorial portrayal of a calculation.
- The guidance of pseudo code is composed by utilizing English expression and numerical articulation.
- Q-BASIC is a general programming language created by Microsoft Corporation, USA for microcomputers in 1985. It involves Interpreter as a language interpreter program. It utilizes a bunch of catchphrases and numerical images to compose programs.
- An amount in a PC program which doesn’t change its worth during the execution of the program is known as a steady.
- The amount which might change its qualities during the execution of the program is known as the variable.
- An articulation can be a string, or numeric consistent, a variable or a blend of constants, factors with administrators which return a solitary worth.
- Operands are the information or factors on which numerical, intelligent and string tasks occur.
- Administrators are the images, which are utilized in number-crunching activities, sensible articulations, and string articulations.
- An assertion is a bunch of directions composed utilizing catchphrases or orders of QBASIC. Each programming language involves catchphrases as a proclamation with specific sentence structure.
- The explanations which are utilized to characterize and announce the qualities, factors, constants and so on for programming intention are known as statement proclamation. The announcement explanations are DIM, REM, CONST, DECLARE and so forth.
- The explanations which are utilized to dole out the worth to the connected variable are known as task proclamations. The task articulations are Let, Swap and so on.
- The explanations which are utilized to give contribution to factors of QBASIC program for handling and show the outcome as result on the screen are known as info/yield articulation. The info/yield explanations are : CLS, INPUT, LINE INPUT, PRINT, PRINT USING and so on.
- The explanations which are utilized to move the control of program starting with one section then onto the next part regardless of condition are known as control proclamations. The control explanations are IF THEN, SELECT CASE, FOR NEXT, DO LOOP, ON GOTO and so on.
Read More: Computer Applications: Secondary Level: Unit-4: 4.1 Programing Language And Fourth Generation Language
Read More: Computer Applications: Secondary Level: Unit-4: 4.2-4.3: Kinds Of Language Processor Software: Distinction among Program and Software: