0% found this document useful (0 votes)
56 views3 pages

Key BASIC Programming Statements

The document outlines key statements in the BASIC programming language, including line numbers, CLS, remark, assignment, output, conditional, and unconditional statements. It explains the purpose and syntax of each statement, providing examples for clarity. Additionally, it includes an assignment task for further learning on BASIC statements.

Uploaded by

nkechienechukwu
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views3 pages

Key BASIC Programming Statements

The document outlines key statements in the BASIC programming language, including line numbers, CLS, remark, assignment, output, conditional, and unconditional statements. It explains the purpose and syntax of each statement, providing examples for clarity. Additionally, it includes an assignment task for further learning on BASIC statements.

Uploaded by

nkechienechukwu
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

BASIC PROGRAMMING LANGUAGE CONTINUES

BASIC KEY STATEMENTS

Statement is a set of instruction written by using key words or commands of QBASIC. Some common BASIC keywords
used to form BASIC statements are;
- Line number
- CLS statement
- Remark statement
- Assignment statement
- Output statement
- Program terminator, etc.

LINE NUMBER:

Every BASIC statement must begin with a line number which can vary between 1 and 9999. Instructions are carried out
or executed in the order in which they are numbered. E.g.
10 INPUT A
20 INPUT B
30 LET C = A + B
40 END

CLS STATEMENT:

The CLS statement clears the screen. The syntax is CLS and it is used for clearing unexpected display on the screen.
E.g.
10 CLS
20 REM “This program will calculate the total of two numbers”
30 INPUT A
40 INPUT B

REMARK STATEMENT:

The remark statement is represented using “REM” . It is used to introduce the program to the computer and it is an
optional statement. E.g.
10 REM “This program will calculate the total of two numbers”
20 INPUT A
30 INPUT B
40 END

PROGRAM TERMINATOR:

The program terminator is used to specify the end point in a BASIC program. E.g.
END/STOP command

ASSIGNMENT STATEMENT:

Assignment statement is used to assign values to variables.

TYPES OF ASSIGNMENT STATEMENT

- LET statement
- INPUT statement

Week nine Computer Studies Lesson note for JSS2 1


- DATA statement

LET STATEMENT

This is an assignment statement used to assign value to a variable. E.g.

LET A = B
LET C = A+B
LET B$ = ”THANK YOU”

INPUT STATEMENT

The input statement allows a value, numeric or character string to be typed into the computer and stored in the
computer. E.g.
10 INPUT A

DATA STATEMENT

The READ and DATA statement work hand in hand. They are used instead of the INPUT statement when large amount
of data is to be entered into the computer. E.g.
10 READ A, B, C, D
20 DATA 20,30,40,50

OUTUT STATEMENT

The output statement is used to display the result of the task assigned to it. E.g. PRINT

30 PRINT “computer is a dummy”

CONDITIONAL STATEMENT

Conditional statements are dependent on certain conditions and criteria before they can be executed if conditions are
true or order actions may be taken if conditions are false. E.g.
30 IF A > 80 THEN PRINT A
40 ELSE PRINT B
50 END

UNCONDITIONAL STATEMENT

Unconditional statements are statements used to transfer control from one part of the program to another. E.g.

GOTO and RETURN statements

10 CLS
20 INPUT A
30 INPUT B
40 LET C = A+B
50 GOTO 60
60 PRINT C
70 END

ASSIGNMENT

Mention 10 other key statements used in BASIC and state their uses.
Week nine Computer Studies Lesson note for JSS2 2
Week nine Computer Studies Lesson note for JSS2 3

Common questions

Powered by AI

In BASIC, the DATA statement stores information that can be referenced by other parts of a program, while the READ statement retrieves this data. This setup is particularly useful for handling large datasets, as it separates data entry from data use. For example, using 'READ A, B, C, D' and 'DATA 20,30,40,50,' the program can efficiently load and utilize multiple data points without repeatedly prompting for input, streamlining data management .

The REMARK statement, denoted by 'REM,' serves an important role in documenting and explaining the function of code segments within a BASIC program. While not executed by the program, it provides comments like 'REM “This program will calculate the total of two numbers”' to outline the purpose of specific code blocks or the program as a whole, facilitating easier understanding and maintenance .

Unconditional statements such as GOTO and RETURN in BASIC modify the program flow by transferring control directly from one part of the program to another without the need for conditions. For example, GOTO can redirect code execution to a different line number immediately, as in 'GOTO 60,' affecting the typical sequential execution order .

Conditional statements in BASIC control the program's flow by executing specific lines of code if a certain condition holds true. For instance, the statement 'IF A > 80 THEN PRINT A ELSE PRINT B' checks if 'A' exceeds 80; if true, it prints 'A,' otherwise, it prints 'B.' This conditional logic is crucial for decision-making within programs, facilitating dynamic responses to variable states .

The CLS statement in a BASIC program is used to clear the screen. Its syntax is simply 'CLS,' and it helps in clearing unexpected displays on the screen before the execution of subsequent commands .

In BASIC, assignment statements are used to assign values to variables. The 'LET' statement explicitly assigns a value to a variable, such as 'LET A = B.' The 'INPUT' statement allows for value input from the user to be stored in the program, like 'INPUT A.' The 'DATA' statement, often used with 'READ,' is applied for entering large amounts of data into the program, as demonstrated in 'READ A, B, C, D' and 'DATA 20,30,40,50' .

The OUTPUT statement, identified by the keyword 'PRINT' in BASIC, is utilized to display results. For example, 'PRINT 30' will display the number 30, and 'PRINT "computer is a dummy"' will output the string 'computer is a dummy' to the screen, allowing for the representation of computed results or messages .

The PROGRAM TERMINATOR in BASIC, represented by 'END' or 'STOP,' signifies the conclusion of a program's operations. Including a terminator is critical as it indicates that the program should cease execution, preventing unintended operations or errors once the intended processes are complete .

Line numbers in BASIC are essential as they dictate the sequence in which instructions are executed. Each BASIC statement begins with a line number, which can range from 1 to 9999, ensuring that instructions are carried out in the numeric order specified by these line numbers .

INPUT statements in BASIC facilitate user interaction by allowing the entry of data directly from the keyboard into the program. For instance, 'INPUT A' prompts the user to type in a numeric or string value, which is then stored for further processing in the program. This functionality is key for creating interactive programs that react to user-provided information .

You might also like