Skip to content
HeadTeacher.ng
Lesson Notes

Lesson Note on Basic Programming II: Writing Programs to Compute Algebraic Equations for SSS 2

This lesson note on Basic Programming II for SSS 2 covers writing BASIC programs using built-in functions to compute square roots, trigonometric values and plot waves.

Published Reading8 min Comments0

Class: Senior Secondary School 2 (SS2 / SSS2)
Term: 3rd Term
Week: 6
Age: 16 years
Duration: 45 minutes
Subject: Computer Studies
Curriculum Theme: Programming and Algorithms
Previous Lesson: Basic Programming II: Algebraic Expression Notations in BASIC.
Topic: BASIC PROGRAMING II
Subject Matter: Write a BASIC program to compute algebraic equations (square root and rounding, square root in a range, cosine values, tangent values, plot sine wave curve, plot cosine curve)

Specific Objectives

By the end of the lesson, pupils should be able to:

Cognitive Domain:

  • Define built-in mathematical functions in BASIC.
  • Explain how to use built-in functions for various mathematical computations.

Affective Domain:

  • Appreciate the efficiency of using built-in functions in programming.
  • Develop interest in solving mathematical problems using BASIC programming.

Psychomotor Domain:

  • Write BASIC programs using built-in functions for square root, rounding, cosine, and tangent.
  • Run BASIC programs to plot sine and cosine curves.
  • Interpret the output of BASIC programs.

Social Domain:

  • Collaborate with peers to debug simple BASIC programs.

Reference Materials

The following resources were used in planning this lesson:

  • Senior Secondary Schools Education Curriculum
  • State Unified Scheme of Work
  • Comprehensive Computer Studies for Senior Secondary Schools, Book 2

Instructional Materials

The teacher will teach this lesson with the aid of:

  • Computer system
  • BASIC programming environment (e.g., QBASIC)
  • Sample code printouts
  • Graph paper

Rationale for the Lesson

This lesson helps pupils understand how to use pre-defined functions in BASIC programming. This knowledge is important for solving complex mathematical and scientific problems efficiently using programming, which is a valuable skill in various fields.

Prerequisite/Previous Knowledge

Pupils should have a basic understanding of BASIC programming syntax, variables, and simple input/output commands.

Lesson Content/Board Summary

BASIC Programming II: Built-in Mathematical Functions

Introduction to Built-in Functions

Built-in functions are pre-defined routines or commands that perform specific tasks. They simplify programming by allowing programmers to use common operations without writing the code from scratch. BASIC has several built-in mathematical functions.

Square Root Function (SQR)

The SQR() function returns the square root of a non-negative number. The number must be enclosed in parentheses.

Syntax: SQR(number)

Example 1: Finding the square root of a constant.

PRINT SQR(25)

Output: 5

Example 2: Finding the square root of a user-entered number.

INPUT "Enter a number: ", N
PRINT "The square root is: ", SQR(N)

Rounding Function (INT)

The INT() function returns the largest integer less than or equal to the given number (it truncates the decimal part). For positive numbers, it effectively rounds down.

Syntax: INT(number)

Example 1: Rounding down positive numbers.

PRINT INT(7.8), INT(7.2)

Output: 7 7

To round to the nearest integer, you can use INT(X + 0.5) for positive numbers.

Example 2: Rounding to the nearest integer.

PRINT INT(7.8 + 0.5)
PRINT INT(7.2 + 0.5)

Output: 8 7

Square Root in a Range

To find the square root of numbers within a specific range, a loop structure like FOR...NEXT can be used with the SQR() function.

Example: Calculating square roots for numbers from 1 to 5.

FOR X = 1 TO 5
    PRINT "Square root of "; X; " is "; SQR(X)
NEXT X

Output:
Square root of 1 is 1
Square root of 2 is 1.414214
Square root of 3 is 1.732051
Square root of 4 is 2
Square root of 5 is 2.236068

Cosine Function (COS)

The COS() function returns the cosine of an angle. The angle must be specified in radians, not degrees.

Syntax: COS(angle_in_radians)

Note: To convert degrees to radians, use the formula: radians = degrees * (PI / 180), where PI is approximately 3.14159.

Example: Finding the cosine of 90 degrees (PI/2 radians).

PI = 3.14159
PRINT COS(PI / 2)

Output: ~0 (a very small number close to zero due to floating-point precision)

Tangent Function (TAN)

The TAN() function returns the tangent of an angle. The angle must be specified in radians.

Syntax: TAN(angle_in_radians)

Example: Finding the tangent of 45 degrees (PI/4 radians).

PI = 3.14159
PRINT TAN(PI / 4)

Output: ~1 (a number close to one)

Plotting Sine Wave Curve

Plotting a sine wave involves calculating sine values for a range of angles and then plotting these points on a graph. In BASIC, this typically uses a loop and graphics commands (like PSET or similar, depending on the specific BASIC environment).

Logic:

  • Define PI (3.14159).
  • Set up a graphics screen mode.
  • Loop through angles (e.g., from 0 to 360 degrees).
  • Convert each angle to radians.
  • Calculate Y = SIN(angle_in_radians) * scale_factor.
  • Plot the point (X, Y) on the screen.

Sample (Conceptual) Code:

SCREEN 12 ' High-resolution graphics mode
PI = 3.14159
FOR DEGREE = 0 TO 360 STEP 1
    RADIANS = DEGREE * (PI / 180)
    Y_VALUE = SIN(RADIANS) * 100 ' Scale for screen
    X_SCREEN = DEGREE + 100 ' Offset X for screen
    Y_SCREEN = 200 - Y_VALUE ' Offset Y for screen (200 is center)
    PSET (X_SCREEN, Y_SCREEN), 15 ' Plot point in white
NEXT DEGREE
END

Plotting Cosine Curve

Similar to plotting a sine wave, plotting a cosine curve involves calculating cosine values for a range of angles and plotting these points.

Logic:

  • Define PI (3.14159).
  • Set up a graphics screen mode.
  • Loop through angles (e.g., from 0 to 360 degrees).
  • Convert each angle to radians.
  • Calculate Y = COS(angle_in_radians) * scale_factor.
  • Plot the point (X, Y) on the screen.

Sample (Conceptual) Code:

SCREEN 12 ' High-resolution graphics mode
PI = 3.14159
FOR DEGREE = 0 TO 360 STEP 1
    RADIANS = DEGREE * (PI / 180)
    Y_VALUE = COS(RADIANS) * 100 ' Scale for screen
    X_SCREEN = DEGREE + 100 ' Offset X for screen
    Y_SCREEN = 200 - Y_VALUE ' Offset Y for screen (200 is center)
    PSET (X_SCREEN, Y_SCREEN), 14 ' Plot point in yellow
NEXT DEGREE
END

Teaching Methods/Instructional Techniques

Discussion, Lecture, Demonstration, Question and Answer, Visual Aids

Instructional Procedures

Step 1: Introduction

Time: 5 minutes
Teaching Skill: Set Induction
Teacher’s Activity: The teacher greets the pupils and asks them to recall what they learned in the previous lesson about basic programming concepts. The teacher then introduces the topic of built-in mathematical functions in BASIC programming.
Pupils’ Activity: Pupils respond to the questions and listen attentively to the introduction of the new topic.
Learning Point: Pupils recall previous knowledge and are prepared for the new lesson.

Step 2: Explanation of Built-in Functions

Time: 7 minutes
Teaching Skill: Explanation/Definition
Teacher’s Activity: The teacher defines built-in functions in BASIC and explains their importance in simplifying complex calculations. The teacher introduces the SQR() and INT() functions.
Pupils’ Activity: Pupils listen and take notes, asking questions for clarification.
Learning Point: Pupils understand the concept and purpose of built-in functions.

Step 3: Demonstration of SQR and INT

Time: 8 minutes
Teaching Skill: Demonstration/Practical Application
Teacher’s Activity: The teacher demonstrates how to use the SQR() function to find square roots and the INT() function for rounding numbers with practical examples on a computer or whiteboard. The teacher also shows how to round to the nearest integer using INT(X + 0.5).
Pupils’ Activity: Pupils observe the demonstrations and practice writing simple programs for these functions.
Learning Point: Pupils learn to apply SQR() and INT() functions correctly.

Step 4: Demonstration of SQR in a Range

Time: 7 minutes
Teaching Skill: Demonstration/Looping
Teacher’s Activity: The teacher demonstrates how to combine the SQR() function with a FOR...NEXT loop to calculate square roots for a range of numbers. The teacher shows a sample program and its output.
Pupils’ Activity: Pupils follow the demonstration and try to write their own loop programs.
Learning Point: Pupils understand how to use functions within loops for repetitive tasks.

Step 5: Demonstration of COS and TAN

Time: 8 minutes
Teaching Skill: Explanation/Conversion
Teacher’s Activity: The teacher introduces the COS() and TAN() functions, emphasizing that they require angles in radians. The teacher explains how to convert degrees to radians and demonstrates examples for both functions.
Pupils’ Activity: Pupils pay attention to the radian conversion and practice with given angles.
Learning Point: Pupils learn to use COS() and TAN() and the importance of radian conversion.

Step 6: Explanation of Plotting Sine/Cosine Curves

Time: 5 minutes
Teaching Skill: Conceptualization/Visualization
Teacher’s Activity: The teacher explains the concept of plotting sine and cosine curves using BASIC, outlining the steps involved (looping through angles, converting to radians, calculating values, and plotting). The teacher provides conceptual code or shows a printout of sample code.
Pupils’ Activity: Pupils listen and try to visualize the plotting process, asking questions about graphics commands.
Learning Point: Pupils understand the logic behind plotting mathematical curves in BASIC.

Step 7: Evaluation/Review

Time: 5 minutes
Teaching Skill: Questioning/Assessment
Teacher’s Activity: The teacher evaluates the learning by asking the following questions:

  1. What is the purpose of a built-in function in BASIC?
  2. Write a BASIC statement to find the square root of 81.
  3. Explain how to round a positive number to the nearest integer using the INT() function.
  4. What unit of angle does the COS() function expect? How would you convert 60 degrees to this unit?

Pupils’ Activity: Pupils answer orally and in writing.
Learning Point: Pupils demonstrate understanding of the lesson.

Step 8: Conclusion

Time: 1 minute
Teaching Skill: Summarization
Teacher’s Activity: The teacher summarizes the lesson by reiterating the importance of built-in functions for mathematical computations and plotting in BASIC. The teacher assigns homework: “Write a BASIC program to find the tangent of angles from 0 to 90 degrees, incrementing by 15 degrees.”
Pupils’ Activity: Pupils listen to the summary and copy the homework assignment.
Learning Point: Pupils consolidate their understanding and receive further practice.

Lesson Keywords

  • SQR – Square root function
  • INT – Integer (rounding) function
  • COS – Cosine function
  • TAN – Tangent function
  • Built-in functions – Pre-defined routines in a programming language
  • BASIC – Beginners’ All-purpose Symbolic Instruction Code
  • Plotting – Graphically representing data points
  • Sine wave – A mathematical curve that describes a smooth repetitive oscillation
  • Cosine curve – A mathematical curve similar to a sine wave, but shifted
  • Radians – A unit of angle measurement, where 1 radian is the angle subtended at the center of a circle by an arc equal in length to the radius

Differentiation

For struggling learners, the teacher will provide simpler, step-by-step examples and direct assistance in writing programs. Advanced learners will be challenged to explore other mathematical functions in BASIC (e.g., LOG, EXP) or modify the plotting programs to include labels or different colors.

Note for teachers using this lesson plan

Ensure that a functional BASIC programming environment is available for practical demonstration and pupil practice. Encourage pupils to experiment with different values and observe the output. Emphasize the importance of understanding the units required by trigonometric functions (radians vs. degrees).

Export this post
Lesson Note on Basic Programming II: Writing Programs to Compute Algebraic Equations for SSS 2
About the author

Royal Alikor

Royal Alikor is an educator with six years of classroom teaching and three years of elementary school leadership experience. He develops and reviews practical, curriculum-aligned learning materials for Nigerian schools.

Community Join the conversation Open discussion +