0% found this document useful (0 votes)
78 views22 pages

Christmas Term - JS 2 ICT - Week 9-10 - BASIC Programming I & II

basic programming
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)
78 views22 pages

Christmas Term - JS 2 ICT - Week 9-10 - BASIC Programming I & II

basic programming
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

Lesson Outlines:

Students should be able to:


✓State the full meaning of 'BASIC'.
Week 9 ✓List the BASIC character sets.
BASIC Programming I ✓List some BASIC statements and their meanings.
✓List BASIC arithmetic operators.
✓Write BASIC notations for arithmetic expressions.
✓Write simple BASIC programs.
• BASIC is for Beginners All-purpose Symbolic Instruction Code.
BASIC • It is a family of general-purpose, high level programming languages and is
a simple but powerful language designed for beginners and ease of use.
Programming
• It was developed by Professor John Kemeny and Thomas Kurtz in 1964 at
Language Dartmouth College, U.S.A, as a means of teaching students a simple
language for programming a computer.
Some of the versions of BASIC are:
1. T-BASIC (Turbo BASIC)
2. justBASIC
Versions of 3. BASIC PLUS
BASIC pl 4. GW BASIC (Greg Whitten)
5. Microsoft Q-BASIC (QUICK BASIC)
6. Microsoft Visual BASIC.
The BCSs are set of characters that are
used to construct the grammar of the BASIC
Programming language.
NOTE: You cannot use any character
BASIC Character Sets outside this set while writing a BASIC
(BCSs) program.
There are three types of characters used in BASIC. These are:
1. Alphabetic Characters — A - Z and a - z
2. Numeric Character — 0 - 9 and A-F or a-f for hexadecimal
numbers
3. Special characters – see next slide
10. Single quotation ‘
11. Double quotation “
3. Special Characters 12. Semi colon ;
1. Blank 13. Colon :
14. Exclamation !
2. Equal sign =
15. Question mark ?
3. Plus sign + 16. Ampersand &
17. Less than <
4. Minus sign –
18. Greater than >
5. Multiply * 19. Per cent %
6. Division / 20. Pound £
21. Dollar $
7. Parenthesis ( ) 22. Greater than or equal to >=
8. Comma , 23. Less than or equal to <=
24. Not equal to <>
9. Full stop .
25. Exponential ^ or **
E.g. 4^2 = 4x4 = 16
4^3 = 4x4x4 = 64
10^7 = 10 000 000
➢BASIC Statements are words that give
instruction to the computer while a program
is being run or executed.
BASIC
Statements/Keywords ➢They have special meaning in programming
language apart from their normal English
meaning.
➢They are also called RESERVE WORDS.
1. CLS (CLear Screen)

BASIC This command clears everything on the screen. Every BASIC program must
begin with CLS to avoid getting unexpected display on the screen.
Statements
2. REM Statement (REMark)
The REM statement is a remark
statement. A BASIC statement that
BASIC begins with REM is not executed. Is
Statements…cont used to add comment to a program.
Example:
REM This program finds the average of
5 numbers.
3. LET STATEMENT
Used to assign (or give) values to variables.
A variable is like a container that is used hold/assign a value in programming

BASIC Examples:
Statements …cont LET A = 5
LET AB = 13
LET SUM = A + AB=18

Therefore, A, AB and SUM are variables, while 5, 13 and 18 are values.


4. INPUT STATEMENT
Input is used to assign values to variables
with a keyboard while the program is
running.
BASIC
Statements … cont Examples:
INPUT “Enter the first number”; A
INPUT “Enter the second number”; B
or
INPUT A, B, C
5. PRINT STATEMENT
The print statement tells your computer to display
the output of the executed program on the screen.
OR The PRINT statement will display/output the
result on the screen
BASIC
Statements …
Examples:
LET A = 5
LET AB = 13
LET SUM = A + AB
PRINT SUM
6. END STATEMENT
The End statement is an instruction used to terminate/end
the program.

Example:
BASIC END
Statements …
Examples:
LET A = 5
LET AB = 13
LET SUM = A + AB
PRINT SUM
END
7. RUN STATEMENT
Used to execute or run a program in the
memory. In justBASIC, Shift + F5 is used to
RUN a program.

BASIC 8. The READ and DATA statement


They work together. They are used when large
Statements …
amount of data is to be entered into the
computer through the keyboard.
For example:
10 READ A, B, C, D
20 DATA 20,30,40,50
9. LIST
This command is used to check a program and
correct errors before running it.
10. NEW
BASIC This command deletes or erases existing programs in
Statements… the main memory in order to allow entry of another
program.
11. SAVE
This command is used to store your program in the
main memory into the specified auxiliary storage.
1. A comment in BASIC program is usually indicated by _____
(a) COMMENT (b) DIM (c) REM (d) DATA
2. …….. is not a keyword in BASIC language. (a) INPUT (b) END (c) GET (d)
LET
3. All BASIC programs must end with….. (a) CLS (b) END (c) PRINT (d) DATA
4. The …………. statement is added at the end of a BASIC program (a)
END (b) CANCEL (c) Data (d) Assign
Evaluation
5. BASIC Programming Language was developed in ……….. College USA
(a) Dowen (b)Dartmouth (c)Stanford (d) Queens
6. …….. statement allows you to type in data from the keyboard when the
program is running (a) Hardware (b)INPUT (c)Software (d) Peripheral
7. BASIC was developed in the year ……… (a)1961 (b)1962 (c)1963 (d)
1964
Week 10 Lesson Outlines:
Students should be able to:
BASIC ✓Carry out simple arithmetic operations in BASIC
Programming II ✓Write simple BASIC programs involving strings and numeric data
SIMPLE BASIC
PROGRAMs
REM A This program teaches students of JS 2A how to write a simple BASIC program like
calculating the sum, subtraction, division and multiplication of numbers.
CLS
LET A = 4
LET B = 7
LET C =9
LET D = 12
LET E = A + B + C + D
LET F = A - B - C – D
LET G = C/D
LET H = A * B * C * D
PRINT “The SUM is”; E
PRINT “The DIFFERENCE is”; F
PRINT “The DIVISION is”; G
PRINT “Their PRODUCT is”; H
END
1
Note: 𝐴𝑟𝑒𝑎 𝑜𝑓 𝑎 𝑡𝑟𝑖𝑎𝑛𝑔𝑙𝑒 = 𝑏𝑎𝑠𝑒 𝑥 ℎ𝑒𝑖𝑔ℎ𝑡
2

Write a BASIC 10 REM PROGRAM TO COMPUTE THE AREA OF A TRIANGLE


program to 20 INPUT "Enter Base Length "; BL
compute the 21 INPUT "Enter Height "; HT
area of a 30 AREA = 0.5 * BL * HT
50 PRINT “The area of the triangle is "; AREA
triangle.
60 END
 CLS
 REM This program calculates the simple interest on $10, 000 for 3 and half
years at the rate of 5.5%.
A BASIC  LET P = 10000
program to  LET R = 5.5
find the Simple  LET T = 3.5
Interest  LET SI = (P*R*T)/100
 PRINT SI
 END
Write a BASIC program to calculate the sum and
average of six integer numbers and print the result.

10 REM PROGRAM TO ADD AND AVERAGE SIX INTEGER NUMBERS


20 INPUT "Enter the first number M1: "; M1
30 INPUT "Enter the second number M2: "; M2
31 INPUT "Enter the third number M3: "; M3
32 INPUT "Enter the fourth number M4: "; M4
33 INPUT "Enter the fifth number M5: "; M5
34 INPUT "Enter the sixth number M6: "; M6
40 SUM = M1 + M2 + M3 + M4 + M5 + M6
90 AVER = SUM/6
100 PRINT "The sum of the six integers is "; SUM
110 PRINT "The Average of the six integers is ",AVER
120 END
1. Define Programming Language [2]
2. What is a Computer Program? [2]
3. List the two levels of programming languages.
4. What is the full meaning of BASIC?
5. List FIVE versions BASIC
Theory 6. Write a BASIC program to find the product of two numbers
Questions 7. List FIVE examples of ICT gadgets
8. BASIC is an example of Assembly language _______ [T/F?]
9. Write the full meaning of the following:
i. BITs
ii. BASIC
iii. COBOL

You might also like