Lesson Notes By Weeks and Term - Senior Secondary 1

BASIC programming language II

Term: 2nd Term

Week: 10

Class: Senior Secondary School 1

Age: 15 years

Duration: 40 minutes of 2 periods each

Date:

Subject:      Computer Studies and ICT

Topic:-       BASIC Programming language II

SPECIFIC OBJECTIVES: At the end of the lesson, pupils should be able to

  1. Describe how a BASIC expression is formed
  2. Outline the arithmetic operation precedence
  3. State some BASIC statements and their meaning
  4. Give some examples of QBASIC

INSTRUCTIONAL TECHNIQUES: Identification, explanation, questions and answers, demonstration, videos from source

INSTRUCTIONAL MATERIALS: Videos, loud speaker, pictures, Data Processing for senior Secondary Education by Hiit Plc, WAPB Computer Studies for Senior Secondary I by Adekunle et al, On-line Materials.

INSTRUCTIONAL PROCEDURES

PERIOD 1-2

PRESENTATION

TEACHER’S ACTIVITY

STUDENT’S ACTIVITY

STEP 1

INTRODUCTION

The teacher reviews the previous lesson on the BASIC programming languages

Students pay attention

STEP 2

EXPLANATION

He describes how a BASIC expression is formed and outlines the correct arithmetic operation precedence in BASIC.

 

Students pay attention and participates

STEP 3

DEMONSTRATION

He states some BASIC statements and explains their meaning. He also gives some examples of QBASIC

Students pay attention and participate

STEP 4

NOTE TAKING

The teacher writes a summarized note on the board

The students copy the note in their books

 

NOTE

BASIC PROGRAMMING LANGUAGE

Basic Expression

A BASIC expression is formed when two or more character, strings, variables or constant are combined with arithmetic, relational or logical operators

Examples include:

  1. F2 + 7 (add 7 to the value in the variable F2)
  2. A+ B (add the value in A to the value in B)

 

Arithmetic operation precedence

The rule that guides the order in which operation must be performed in an expression is known as “precedence” rule.

THE ORDER

SYMBOL

NAME OF SCHOOL

1

( )

Bracket

2

^

Exponentiation

3

-

Negation

4

*or /

Multiplication

5

\

Integer

6

MOD

Modulo (remainder)

7

+ or -

Addition or subtraction

 

BASIC statements

A BASIC statement is any valid instruction given to the computer for processing of data. BASIC statement may be an expression, an assignment, a reserved word (keyword) with or without arguments or their logical combinations

  1. Declaration statement: Every variable in a program must be declared before it can be used. A variable must be declared with appropriate data type. Example of declaration statements are:

DIM Age AS Integer

DIM Name AS Character

  1. Assignment statement: This statement causes a computer to store a value in a variable. The statement has two sides separated by the equality sign (=).

Name = “Computer Studies”

Age = 16

  1. Input statement: This statement is used to ask the user to supply the data to be processed while the program is executing.

INPUT Name$, Age%       (This statement is not interactive)

INPUT “Enter the Name and Age”, Name, Age          (This statement is interactive)

  1. READ and DATA statement: The READ statement is used to supply data into the program, but unlike the INPUT statement, the programmer supplies the data inside the program codes using the DATA keyword.

READ “Enter Name and Age”, Name$, Age%

DATA “Obasa Mustapha”, 20

  1. PRINT statement: This statement is used to show the result of data processed.

 

QBASIC program examples

 1    REM This program calculates the area of any rectangle and print the length, width, and area.

2    ‘To calculate the Area of a Rectangle we must know its length and width"

3    Length = 10



4    Width = 6

5     Area = length * breadth

6    PRINT “Area is “, Area

7    END

 

10 REM program to solve a quadratic equation

20 INPUT “Enter coefficients a, b, c “; a,b,c

30 Discrim = b^2 – 4*a*c

40 If Discrim > 0 then

50 Dummy = sqr(Discrim)

60 PRINT “There are 2 distinct roots”

70 PRINT “first root (X1) = “; (-b + dummy)/(2*a)

80 PRINT “Second root (X2) = ”; (-b –dummy)/ (2*a)

90 ELSEIF Discrim = 0 THEN

91 PRINT “There is only 1 root, the 2 roots coincide”


92 PRINT “double root = ”;  - b / (2*a)

93 ELSE

94 PRINT “The roots are imaginary”

95 Dummy = sqr (- discrim)

96 PRINT “Real part = “; - b /(2*a)

97 PRINT “Imaginary part = ”; dummy/(2*a)

98 END IF

99 END

 

EVALUATION:    1. Give one example of a BASIC expression

  1. List and explain three statements in BASIC
  2. What is the precedence of arithmetic operations in                    BASIC?
  3. Write a QBASIC program for the below problem

 1    REM This program calculates the area of any rectangle and print the length, width, and area.

2    ‘To calculate the Area of a Rectangle we must know its length and width"

3    Length = 8
4    Width = 5

5     Area = length * breadth

6    PRINT “Area is “, Area

7    END

 

CLASSWORK: As in evaluation

CONCLUSION: The teacher commends the students positively