Here is a term paper on ‘BASIC Programming Language’ for class 11 and 12. Find paragraphs, long and short term papers on ‘BASIC Programming Language’ especially written for college and IT students.

Term Paper on BASIC Programming Language


Term Paper Contents:

  1. Term Paper on the Introduction to BASIC Programming Language
  2. Term Paper on the Structure of BASIC Programming Language
  3. Term Paper on Character Set Permitted in BASIC Programming Language
  4. Term Paper on the Constants Used in BASIC Programming Language
  5. Term Paper on Variables and BASIC Programming Language
  6. Term Paper on Arithmetical Operation and BASIC Programming Language
  7. Term Paper on Data Input and BASIC Programming Language
  8. Term Paper on the TAB Function Provided in BASIC Programming Language
  9. Term Paper on the Commands in BASIC Programming Language
  10. Term Paper on the Program Control in BASIC Programming Language


Term Paper # 1. Introduction to BASIC Programming Language:

BASIC, which is an acronym, a short form, of Beginner’s All Purpose Symbolic Instruction Code, is a high-level language of immense popularity. Any person, who calls himself a programmer, will at least know this language, which has all the nuances of different programming techniques.

ADVERTISEMENTS:

This is certainly the best language to begin to learn computer programming. Although, there are hundreds of different versions of BASIC, it was originally developed by John Keremy and Thomas Kurtz at Dartmouth College, in mid-1960s.

As newer versions started coming up, offering different facilities and with different syntax, the American National Standard Institute, popularly known as ANSI, standard­ized the basics of the BASIC language in 1978, which is called ANSI BASIC — which is provided in all the versions of BASIC.

What we will discuss in this course is the interpretive BASIC provided with MS DOS as BASIC A or GW-BASIC; restricting ourselves to the ANSI portion only. This software provides the environment, when loaded for writing and running programs, with built-in editing facilities. To start BASIC, just enter the name of the file — BASICA or GW-BASIC at the DOS prompt of A> or C> and press the Return key.

The BASIC will he loaded by MS DOS, providing .the BASIC environment, when the language interpreter takes over the command of the computer. To exit from the BASIC environment, just type SYSTEM and press Return and you will see the DOS prompt again.

ADVERTISEMENTS:

Incidentally, BASIC does not have any prompt like MS DOS, but it responds with OK when waiting for your instruction, which is called Command-level. An OK means you can go ahead to do whatever you want, provided it is permitted under the language.


Term Paper # 2. Structure of BASIC Programming Language:

There is a definite style of giving instructions in BASIC when writing programs, which are executed in what is called indirect mode. All the instructions, which you want to be executed automatically, one after another, are done in the indirect mode and to indicate this, a line number has to be given before each line, which can be any positive integer from 0 to 65,529.

Generally the line numbers are given in multiple of 10, starting with 10, as 10, 20, 30, … etc. This is done to provide scope for program modification, by entering instructions in between the existing lines without having to rewrite the whole thing with new line numbers.

ADVERTISEMENTS:

In the direct-mode, any BASIC statement can be entered without the line number, but starting with an exclamation mark “?” and it will be executed immediately. However, all programs are written for execution in indirect-mode.

The structure of a BASIC program, written in indirect-mode, is as follows:

1. Each instruction forms a separate statement of execution.

2. Each statement begins with a line number, followed by a BASIC keyword — which are reserved words having special meaning, with predefined syntax.

ADVERTISEMENTS:

Hence, the syntax- of a BASIC statement is:

where n stands for line number.

3. Each line number must be unique — no two lines can have the same number. Instructions are executed one by one as per the line numbers, starting with the lowest one; successive statements having increasing line numbers.

ADVERTISEMENTS:

4. Normally only one statement can be written on a line with a distinct line number. However, if colony (:) is used as a separator, then more than one statement can be written on a line, without requiring another line number. But, the maximum number of characters, including blank spaces in a line can only be 255. The screen being 80 column wide, longer lines get wrapped around to the next line automatically and continues.

A BASIC statement is either executable or non-executable depending on the keyword used in the statement. The executable statements are basically program instructions, which are executed by BASIC, as per the instructions given. Before going into the actual statements or writing programs, you have to be familiar with various terms and concepts, which are specific to BASIC.


Term Paper # 3. Character Set Permitted in BASIC Programming Language:

A character denotes any letter, numeric digit, normal punctuation marks or any other special, printable character available in the keyboard, which are used to represent data.

The characters permitted in BASIC are:

A to Z, 0 to 9, +, -, =, *, /, \, ^, (,), ;, ,, ., $, <, >, “, %,!, &, ?, blank-space — that is 26 + 10 + 24 = 60 characters.

In BASIC, lower-case characters are automatically converted to upper-case characters, except when they are enclosed in double-quotation marks.


Term Paper # 4. Constants Used in BASIC Programming Language:

Constants, are similar to the concept that you learnt in school — their values remain unchanged. BASIC provides for two types of constants, called numeric constants and string constants. Numerical quantities, 0 to 9 or combinations with or without decimal points and + or – signs, by themselves are numeric constants. BASIC does not differentiate between integers [whole numbers] and real- numbers [contains fractions represented by decimal values] — whether 26 or 26.345, both are numeric constants.

A numeric constant, that is a number, can be preceded by + or – sign, but + sign is optional. You cannot use a comma between numbers to make them better readable. Large numbers can be represented in exponential form, which uses the powers of 10 as a multiplier — E or D is used in place of 10. For example, 6 x 108 is expressed as 6E8 or 6E+8. The exponent can be negative.

In BASIC, normal range of numeric constants are:

Any character or a series of them including a blank enclosed within the double quotation marks is called a string constant; the maximum length of a string being allowed is 255 characters. These are generally used for proper names. A string constant is also called a literal. The term, “Module 1”, is a string constant.


Term Paper # 5. Variables and BASIC Programming Language:

A variable is a data-name, or an identifier, which is used to store different values during processing of data. For example, you have used variables in algebraic equations in school like x, y, etc. In BASIC, like constants, the variables are of two types called Numeric Variable and String Variable.

The numeric-variables have numeric constants as their values, which takes up different constant values at different stages of execution. The name of a numeric variable can be written using up to 40 characters — letter, numbers, and decimal-point — but the first character must be a letter. For example, AMOUNT, A1, etc., can be used as names of numeric variables.

Likewise, the string-variables, which contain string constants as their values, can be named, however, the last character in the name of a string variable is a $ sign, like, NAME$ = “Ashok Bagchi”; where NAME$ is a string variable.

BASIC provides for three type of numeric variables, called Integers, Single- precision, -and Double-precision variables. The integer variables can hold only integer values, that is, whole numbers, positive or negative. To identify an integer-variable, the last character is a “%” sign.

In case of single-precision variables the last character is an mark. In case of double-precision numeric variables, the last character is a “#” mark. What differentiates the last two variables from each other, is the degree of precision allowed in storing or processing large numbers. Whenever, a variable is created in BASIC, assigning a value to it, a space in main-memory is reserved for it, specifying the storage size.

In case of integers 2 bytes of storage space is allowed, in case of single-precision it is 4 bytes, and in case of double-precision it is 8 bytes — naturally, the last one provides highest degree of accuracy. By default, that is if you do not specify any type then the numerical variables defined are used as single-precision variables.

You must also note that the variables of the three types are three different variables. For example A%, A!, and A# are three different variable names, each distinct from other. Let us take a simple case.

Suppose, A# = 1.2345678901234567890 — a total of 20 digits with a decimal point.

Then if we make:

A! = A# and A% = A#

and ask BASIC to display the values, we will get

A# = 1.2345567890123457 — 16 numbers + decimal point

A! = 1.234568 — 7 numbers plus a decimal point

A% = 1 and A = 1.234568.

You should note that A! and A represent the same values; the last digit in each case has been rounded up and A% has no decimal values. In case of double-precision values, D instead of E is used in the exponential form, like 56 is written as 5D6.

Whenever you use a numeric variable in a statement, make sure that it has a value assigned to it, otherwise by default it will have a zero value. Variables are created whenever any value is assigned to it by using the equality symbol. For example, BAT = 30.25 defines a numeric variable BAT and a value of 30.25 is assigned to it.

Later on, the value of BAT may change during processing. Whenever assigning values, you must remember to use the right type of constants for the right type of variables, or there will be a “Type mismatch”. For example, if you write BAT = “Ashok” it will be an error, because BAT is a numeric variable. Similarly, if you write BAT$ = 1200, it will also be an error and the interpreter will complain about it.


Term Paper # 6. Arithmetical Operation and BASIC Programming Language:

If you are asked the answer of 8 + 4 × 2, and if you had done your home work in school, you would say 16 and not 24 — because the multiplication is done before addition, under the rule called BODMAS. Similarly, in BASIC, there is a distinct and different priority attached to each of the mathematical symbols used, called hierarchy of priority, which are, in order of priority, with 1 having highest priority.

1. ^ — Exponential or power symbol: 2^8 will by 28

2. – — Negation: changing the sign of a number.

3. * — Multiplication

3. / — Floating point division [normal division]

3. \ — Integer division: result is an integer

3. MOD — Modular division: gives the remainder

4. + — Addition

4. – — Subtraction

The operators which are at the same priority level, like + and – with priority 4, are executed from left to right if used in the same formula. The brackets ( ), which have to be used in pairs, are not an operator — their presence changes the order of priority; operators inside the bracket are executed first, under the same priority rule. For example, (8 + 4) * 2 = 24 and not 16, the + operator being within the bracket is executed first.

The mathematical operators are used to connect different numerical variables and or constants to form formula, which is also called an expression. In fact, an expression in BASIC means a constant, the value of a variable, or the result of evaluation of another expression. For example, Y = X + Z*R is an expression.

If X = 10, Z = 12, and R = 30, the expression after evaluation gives 370, which is then assigned to Y, making Y = 370. The value of the right side is assigned to the variable on the left side. As far as string variables are concerned, the + operator can be used to concatenate, to join, two strings. For example, if A$ = “My ” and B$ = “Book”, then AS + B$ would be equal to “My Book”.

When using mathematical operators, you must make the expression explicit. You know that 2A stands for 2 into A, but the computer does not. So, you will have to write it as 2 * A. You can obviously use only one operator between two variables, except the negation operator.

In a division, you cannot have the denominator as zero. Be careful to use the operators keeping in mind their priority, otherwise, you will end up with logical errors. You can use blank space between operators, etc. for better readability.


Term Paper # 7. Data Input and BASIC Programming Language:

Now that you know the importance of data, let us see how BASIC deals with input data. This data, whether it is stored in a file, or being entered by the user on being prompted by the computer during program execution, is assigned to a variable with a distinct name identifying it.

Once a variable with a name is thus created, during execution a definite storage location with a definite size in the main memory is allotted to it and there after, we manipulate the data, not by the address where it is stored but by the name of the variable to which it is attached.

A variable is created by using a reserved word LET, whose syntax is:

The value being provided by a constant, another variable with a value, or by evaluation of an expression like say, C + 10 * D, which evaluates to 32 with C and D being equal to 2 and 3 respectively The equality sign here means assigning-the- value on its right side to the variable on its left side. The type of variable must match with the value assigned to it, otherwise an error of “Type mismatch” will occur — you can not assign a numeric value to a string variable and vice versa.

Because the equality sign is used here for assigning a value, we can have an expression like A = A + 1, or A = A + B, where A and B are variables, which is not valid in algebra, because = sign there means equality only When we write, A = A + 1, what it actually means that: add one to the existing value of A and assign it to A as the new value. So, if previously A was 15, now it will become 16.

In modern BASIC, the word LET need not be used at all, however, for the purpose of examination, you should make a habit of using it. Use of LET makes it easier to understand that it is a statement where an assignment is being made.

In BASIC the assignment sign “=” is also used for testing equality, unlike advanced high level languages like C, etc. Incidentally, with LET statement, only one vari­able can be created at a time — you cannot have LET A, B = 10,15.

Variables can also be created by two other statements, which also assign values simultaneously to one or more variables; one of them being READ .. DATA.

The syntax is:

The DATA statement provides the values for the variables specified in the READ statement, their being one-to-one correspondence, which means, the first value [constant] is assigned to the first variable, the second value is assigned to the second variable, and so on. The values for the corresponding variables must be of the game type to avoid “Type mismatch”.

The string constants given in the DATA statement must be enclosed in quotation marks if it contains comma, or blank spaces at the beginning or end; otherwise the double-quotes are not required. If the number of variables specified in the READ statement is more than the number of constants in the DATA statement, in each case separated by commas, then “Out of data” error occurs during execution. If the number of variables is less, the extra data is ignored.

You have to treat the variables in the READ statement and the constants in the DATA statement as two continuous lists, irrespective of the number of lines used to write them separately and then you will not make any mistake in assigning correct values to variables. Let us take a few examples to demonstrate this aspect.

Example 1:

On execution, A = 6; B = -8.2; C — Type mismatch, a string “Idiot” is as­signed to a numeric variable; D$ = “Smart”; E$ — Type mismatch, a numeric constant 100.632 is assigned to a string variable; F — Type mismatch, a string constant “Sporting” is assigned to a numeric variable; G = 37. The numeric con­stant 82.65 is ignored. Had 37 and 82.65 were omitted, it would have said “Out of data”.

Example 2:

There are 7 constants and 7 variables, but because of the Line Number 40, the assignments get altered. At line 10, A = 1, B = 2, and C = 3 and so, normally at line 50, D would have been assigned 4 — 1,2,3 being already used up. But because of RESTORE at line 40, the data at line 90 gets restored and so at line 50, D = 1, E = 2, F = 4, and G = 4.

If a line number is specified with RESTORE, it revives the constants of the DATA statement of the specified line number only.

The other statement which assigns values to one or more variables, operate in the interactive mode and its syntax is:

The “prompt” is an optional item, which can be used to clarify what type of data is expected by using some narration, like, “Enter your name “, etc. During execution, when this statement is encountered, execution stops, the prompt is displayed if used, and a question mark “?” appears, waiting for entry of the valid type of data in the specified number — the values entered are assigned to the respective variables serially, as provided in the INPUT statement. If the type of values entered are not same as the variables defined and or the number of values is not equal to the number of variables, an error prompt calls “Redo from the start”.

If the semi-colon after the “prompt” is replaced with a comma, then the question mark does not appear during execution, when the program waits for input of values. Like before, string constants can be entered without quotation marks, if it does not contain comma or blank spaces at the beginning or end of it. Each value entered is to be separated by commas.

Example 3:

To demonstrate the effect of comma and semi-colon on formatting.

The data used here are each of 7 digits.

The line 20 prints the output as:

keeping two blank spaces between the numbers; with negative numbers, one space is taken up by the (-) sign.

The output of line 30 becomes:

There being 7 blank spaces between the digits. In each case one blank space is left at the beginning of the line for the (-) sign, if any.

If the number of digits exceed 7, then the data is displayed in exponential form, as shown below:

The output is in exponential form for those with more than 7 digits.

As you can appreciate, the PRINT statement offers only a limited scope for displaying outputs in a well formatted manner. Hence, there is another statement which provides the facilities to display output in neat tabular forms, especially with numerical values.

The syntax is:

The format string provides the formatting set up to be adopted when displaying values, constants, etc. The symbols used are different for string and numeric variables.

Format-string Symbols for String Values:

!:

a ! mark in the format-string specifies that only the first character of the string constants of the list-of-expression are to be displayed

\ n spaces \:

This specifies that (n+2) characters of each string is to be dis­played. If n = 0, only two characters are shown. If the length of the string is less than the number of characters to be displayed, then blank spaces are used to fill up the spaces.

&:

It specifies variable length string, that is, the displayed string is identical with the original string.

Example 4:

Format-String Symbols for Numeric Values:

#:

It specifies the number of digit positions to be displayed. If the number of digit-position is more than the actual digits to be displayed, then the numbers are right justified. A decimal position is displayed using a period (.) .

**:

It is used at the beginning of the format-string to fill up the leading blank spaces with this symbol. It also specifies two digit positions.

$$:

It causes a $ sign to be displayed at the immediate left of the dis­played number. It also specifies two digit position, one of which is $. It can not be used with exponential format. For negative numbers, the (-) sign has to be displayed at end.

**$:

Combines the effect of the above two symbols. It represents 3 digit positions, one of which is $.

,:

Used on the left of the decimal point causes a comma to be displayed to the left of every third digit, which are at the left of the decimal point.

^^^^:

Displays values in exponential form as E+nn or D+nn [double-preci­sion]. Any decimal point position may be specified. The significant digits are left justified. Unless a leading + sign or a trailing + or – sign is specified, one digit position is used to the left of the decimal point to display a space or a sign.

+:

Can be used at the beginning or end of the format string. It causes the sign of the number to be displayed before or after the number.

-:

When used at the end of a format-string, causes negative numbers to displayed with a trailing minus sign.

_:

The underscore causes next character to be displayed as it is.

If the number to be displayed is larger than the specified numerical field, a % sign is displayed in front of the number. It is also displayed when rounding off is done for a number which exceed the field. If the number of digit field is specified as 24, an “Illegal function call” is displayed; as an error. Let us use a simple two line program with numerical values of different width, to see the effect of using different symbols in PRINT USING.


Term Paper # 8. TAB Function Provided in BASIC Programming Language:

Functions are small programs designed for specific output and are built into the language system. There are a number of functions provided in BASIC. A function is called with some parameters; which is called its argument. The output provided by the function is depended on the ar­gument used. To call a function in’ BASIC, just use the name of the function as per given syntax.

For TAB it is — TAB (n) — where n indicates the column position. What this function really does is, takes the cursor to the absolute column position given by the value of n, which has to be between 1 and 80. TAB can only be used with PRINT and LPRINT statements.

If a comma or a semi-colon is used at the end of a line with the PRINT statement, the display continues in the same line, if space is available.


Term Paper # 9. Commands in BASIC Programming Language:

In BASIC, commands and statements are both executable statements — the former being at command level, with no line numbers or even “?” before them.

Some of the commands are:

1. RUN [filename] — executes the program residing in memory. When the filename is specified., it loads and runs the file. It closes all previous open files.

2. RUN [line-number] — executes the program residing in memory, but starting with the line number specified.

3. SAVE filename [,a] — saves the program in the memory to the filename specified in compressed binary format. When [,a] is used, it is saved in ASCII format, which can be seen with the Type command of MS DOS.

4. SAVE filename [,p] — saves the file in encoded binary format, which cannot be seen. An attempt to LIST the program will cause “Illegal function call”.

The SAVE command assigns .bas extension to files saved, unless a different extension is given. If the filename is followed by [,a] or [,p], then it is to be enclosed in double-quotation mark. An existing file with the same name is over written without any warning.

1. LOAD filename — loads a program from disk to memory and assumes .bas as the default file extension. It clears memory of old program and closes all files.

2. LIST [linenumber] [-linenumber] [,filename] — displays the program in memory when used singly, scrolling the lines if required. The linenumbers specified are used as a range, to which the display is restricted. A different filename can be specified to load and display.

3. LIST [linenumber-], [filename] — displays, starting with the linenumber specified; others as before.

4. NEW deletes the program currently in memory.

Different Functions keys have been assigned to 4 commands for quick operation.

These are:

F1 types LIST on the screen. Press return to execute, or modify using line numbers, etc.

F2 types RUN, followed by Return and so is executed immediately.

F3 types LOAD”, when filename is to be typed; no need to close the “.

F4 types SAVE”, when filename is to be typed; no need to close the “.


Term Paper # 10. Program Control in BASIC Programming Language:

The execution of a program, as you know by now, always proceeds in a sequence, one after another, unless some imposed conditions or instructions cause it to deviate from the normal sequential course. In BASIC there are a number of commands which allow you to control the flow of program.

Unconditional Branching:

When the execution of instructions, deviating from normal sequence, moves to a different location it is called branching. In unconditional branching, the control definitely shifts without waiting for any condition to be fulfilled. In fact, no condition is provided for evaluation at all. The command for unconditional branching, which is also used for uncontrolled looping, is GOTO n, where n is a valid line number in the program.

On reaching the GOTO statement, the execution unconditionally branches off to the line number provided in the command and there from the execution continues. Use of GOTO is strongly disfavoured in structured programming.

Relational Operators:

These operators are used to compare two values, the result being given as True [-1] or False [0]. Naturally, these operators are extensively used as conditions in decision making.

The operators are:

These operators are also used for string comparisons, where the equivalent ASCII values are compared; like B is greater than A.

Conditional Branching:

There are two sets of commands providing for conditional branching — where branching takes place only on fulfillment or non-fulfillment of certain condition.

One of the command is called IF – THEN – ELSE, whose syntax is:

In the above statements, the “expression” is evaluated, and if found true a non-zero value is returned and the “statement” after THEN is executed. Other­wise, the statement after ELSE is executed, that is, when the “expression” is found to be false giving a zero value. In the second variation, instead of executing a statement, the control shifts to the line number specified, if the outcome of evaluation is true.

This conditional branching statement can be nested, that is, you can have one set of IF-THEN-ELSE statement within another set of IF-THEN- ELSE statement. If the statements do not contain same number of ELSEs and THENs, each ELSE is matched with the closest unmatched THEN.

For example, in the following program, there is no matching ELSEs and THENs and so we get different output under different conditions, which are different from our expectations in some cases. It will not print A <> C when A <> B.

Example 5:

RUN

A = C

Ok. It does not have to go up to ELSE.

Example 6:

RUN

Ok. No output.