0% found this document useful (0 votes)
28 views10 pages

Lesson Plan For First Term 2024/2025 CSC 301 Week 9-10

Uploaded by

ibehkene3
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)
28 views10 pages

Lesson Plan For First Term 2024/2025 CSC 301 Week 9-10

Uploaded by

ibehkene3
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
You are on page 1/ 10

LESSON PLAN FOR FIRST TERM 2024/2025 CSC 301 WEEK 9-10

NAME: MRS PEACE JOHNSON - OBI

SUBJECT: COMPUTER STUDIES

THEME: COMPUTER PROGRAMMING

TOPIC: BASIC PROGRAMMING III (ONE DIMENSIONAL ARRAY)

INSTRUCTIONAL MATERIALS: A print out of different types of arrays

BIBLICAL INTEGRATION: Rev. 20:12 the database of every man’s record shall be opened on the last
day. Is your name in the lambs’ book of life?

DATE: 04 – 11 – 2024

TIME: 1.20PM – 2.00PM

DURATION: 40 MINUTES

CLASS: SS301 – 303

AVERAGE AGE: 16YEARS

SEX: MIXED

LEARNING OBJECTIVES: By the end of the lesson, the students should be able to:

 Define the term 'array'


 Identify arrays in real world settings
 Declare and initialize an array
 Perform mathematical operations with array elements

RATIONALE: Working with lists in computer memory requires the use of a specific known as array

PRE-REQUISITE KNOWLEDGE: The students have been taught how to create tables

REFERENCE MATERIAL: Computer Studies for Senior Secondary Education by HIIT Plc, Internet

LESSON DEVELOPMENT

STAGE/STEP TEACHER’S ACTIVITIES STUDENT’S ACTIVITIES LEARNING POINT


The teacher introduces The students give their Reviewing the
INTRODUCTION the lesson by passing responses; each previous knowledge;
5 MINUTES round the print out of student that lifted that array is a list
different types of array their hand is permitted containing elements
and find out what they’ll to respond
call that feature
PRESENTATION The teacher asks the The students make Explaining the
5 MINUTES students to explain their different meaning of database
where they’ve seen this attempts
feature in use
STEP 1: The teacher asks to The students are Definition of array
DEFINITION define array in their own allowed to attempt
10 MINUTES terms then teacher defines
STEP 2: The teacher guides the Individual students Guiding the students
DISCUSSION students into the body ok attempt to answer the in answering these
10 MINUTES knowledge by asking the questions. They are question will help in
following questions: encouraged to check building the students’
1. What do you into their textbooks. confidence and foster
understand by the term Based on the participation in class
array responses of the discussions
2. how can array be students, the teacher
created enters the topic
3. What kind of proper.
problems can we solve
with an array?
STEP 3: APPLICATION The teacher asks the The students take note A basic application
4 MINUTES students areas where and ask relevant of Arrays can
array is applied questions. be storing data in
tabular format. For
example, if we wish
to store the contacts
on our phone, then
the software will
simply place all our
contacts in an array.
EVALUATION The teacher evaluates The students answer Ascertaining the
4 MINUTES the learning objectives, the questions and ask attainment of stated
and asks questions thus: relevant questions if learning objectives. In
 What is an array? any. terms of knowledge,
 What are the skills and attitude.
operations possible
in an array
CONCLUSION/ The teacher The students take note Consolidation of
ASSIGNMENT recapitulates the major and ask relevant concept learnt in the
2 MINUTES points of the lesson and questions. lesson, clearing
gives the following misconceptions and
assignments: internalising relevant
1. Create a one knowledge and skills
dimensional array of 4 acquired.
elements
2. Show with an
arithmetic operation
how to access the
elements in the array
created above

LESSON SUMMARY
DEFINITION OF ARRAY IN BASIC
In computer programming, an array is a data structure that stores a fixed-size sequential
collection of elements of the same type. Elements in an array are stored in contiguous
memory locations, making it easy to access each element directly by its index.

Example of an Array:

Consider an array that stores five integers in python coding:

python
An array of integers in Python
numbers = [10, 20, 30, 40, 50]

Here:

 numbers[0] is 10
 numbers[1] is 20
 numbers[2] is 30
 numbers[3] is 40
 numbers[4] is 50

In this example, numbers is an array holding five integers, and each element can be accessed
using its index.

Each object in an array is called an array element and arrays are useful for organizing multiple
variables. Elements of an array are accessed by the use of index (created by the primary key).

Below are some applications of arrays.


 Arrays are used to implement data structures like a stack, queue, etc.
 Arrays are used for matrices and other mathematical implementations.
 Arrays are used in lookup tables in computers.
 Arrays can be used for CPU scheduling.

EXAMPLES OF AN ARRAY
Consider a list of students’ names in a class of 5, a memory variable called “Student” can be created
to hold the names of these students as shown below:

TOLU TINA ELLA GEORGE KARL

Hence, you could have an array of integers, characters, or anything that has a defined data type.
NOTE: 1) The entire array is stored contiguously (i.e there are no gaps between the elements). (2)
Each element has the same data type.
Arrays can have more than one dimension; a one dimensional array is called a vector while a two –
dimensional array (or more) is called a matrix.

ACCESSING AN ARRAY ELEMENT


In BASIC, an array can be accessed with
1. The use of the subscript eg: From the table above, Student1 = Tolu, Student4 = George
2. The use of Parentheses eg: Student (3) = Ella, Student (5) = Karl
3. The use of Brackets eg: Student[2] = Tina, Student[4] = George

OPERATIONS IN AN ARRAY
Arrays can be manipulated in the following ways

A. Input of an Array ( ie storing values in an array): Here, the assignment operator (=) is used eg:
10 DIM Students (5)
20 Students[1] = Tolu
30 Students[4] = George
Eg2 create a one dimensional array to store values for 5 different ages 12, 15, 11, 10 and 14
Solution:
5 DIM ages (5)
10 ages1 = 12
15 ages2 =15
20 ages3 = 11
25 ages4 = 10
30 ages5 = 14
B. Output of an Array : This implies printing or displaying the contents of an array. The PRINT
statement / keyword is used. Eg1:
30 DIM Students (5)
40 PRINT Students

Eg2: Create a 1 – dimensional array that stores 5 different ages 12, 15, 11, 10, 14 and display / print
the ages.
Solution:
10 DIM ages (5)
20 ages1 = 12
30 ages2 =15
40 ages3 = 11
50 ages4 = 10
60 ages5 = 14
70 PRINT ages (1);(2);(3);(4);(5)

C. Arithmetic Operations of an Array: Mathematical operations like addition, subtraction, total, etc
can be performed on the contents of an array.
Eg1. Write a BASIC program to find the average of the ages stored in a one dimensional array with
five elements and print the result.
Solution:
10 DIM ages (5)
20 ages[1] = 12
30 ages[2] =15
40 ages[3] = 11
50 ages[4] = 10
60 ages[5] = 14
70 SUM = ages [1]+[2]+[3]+[4]+[5]
80 Average = SUM /5
90 PRINT Average
100 END

LOOP STRUCTURE IN BASIC


A loop is a set of instructions repeated again and again in a program. The two major statements used
in loop structure in BASIC include: FOR…..NEXT, WHILE…..END
FOR – NEXT : Used to repeat certain portion of a program. The syntax is :
FOR N = 1 TO J
.
.
.
NEXT N

Where 1 and J can either be a constant or a variable of mathematical expressions.


Examples:
1. Write a program extract to store 50 values in a one – dimensional array using a FOR – NEXT
statement
Solution:
5 DIM B (50)
10 FOR I = 1 TO 50
15 INPUT N
20 A(I) = N
25 NEXT I

2.Write a program extract that stores three values 50, 25, 35 in a 1 – DIM array using FOR – NEXT
and print it.
Solution:
2 CLS
4 DIM Classes (3)
6 Classes (1) = 50
8 Classes (2) = 23
10 Classes (3) = 35
12 FOR X = 1 To 3
14 PRINT Classes (X)
16 NEXT X
18 END

3. Using DIM statements and FOR – NEXT construct, write a BASIC program extract to store data in a
vector of 10 integers.
Solution:
10 CLS
20 DIM array (10)
30 FOR I = 1 to 10
40 array (i) ….( ie enter the first value)
50 NEXT i
60 END

Note: Once the first value (i) is entered, it goes to the next statement, after the next, it checks
whether it has reached the valued specified ( ie. To 10). If it has, the program stops, if not, it
continues till it gets to ten (10).
ASSIGNMENT: Solve the following with FOR – NEXT
1. Calculate the Average of a one – dimensional array with 100 numeric values
2. Write a program to output the sum of the first 100 integers
3. Write a program to display the standard deviation of 100 sets of numbers already stored in
an array

WHILE – END : The While – End (WEND) is a command used to specify a loop until a specified
expression is false. To use the while – end, do the following:
1. Place an expression after WHILE
2. Enter a list of commands
3. Place WEND at the end
Examples: 1. Calculate the area of 10 different rectangles or triangles with the while end statement.

Solution:
10 CLS
20 DIM heights (10)
30 DIM bases (10)
40 i = 1
50 WHILE 1<= 10
60 PRINT “Enter base”
70 INPUT bases (i)
80 PRINT “Enter Height”
90 INPUT heights (i)
100 i = I + 1 (initialization)

110 Area = ½* bases (i) * heights (i)


120 FOR I = 1 TO 10
130 PRINT Area;
140 NEXT i
150 END
ASSIGNMENT
1. Write a program to display the roots of the quadratic equation.
2. Write a program extract to calculate the area of 10 different rectangles with FOR – NEXT and
WHLE- END

WEEK 10
HIGH LEVEL LANGUAGES
COMPUTER LANGUAGES
To communicate with the computer, users need a language that will be understood by the
computer hence different languages are developed for performing different types of work
on the computer. Basically, computer languages are divided into two namely:
 Low – level language
 High – level language
The low level languages are the machine codes (0’s and 1’s) or the ones close to it like
mnemonics. There are two low – level languages namely machine language and assembly
language.
The machine language, represented in 0’s and 1’s is the lowest and most elementary of
programming languages; it is the only language that the computer can understand. The
assembly language on the other hand, represented as alphanumeric symbols are known as
mnemonics / numeric codes. It is very difficult, though better than the machine language.
Refer to the advantages and disadvantages of these two languages in your SS1 notes.

DEFINITION OF HIGH LEVEL LANGUAGES


A high level language is a machine independent programming language that enables the
programmer to concentrate on the logic of the problem to be solved rather than the
intricacies of the machine architecture. This means that HLL is problem oriented rather than
machine oriented, more user – friendly and English – like in nature. Examples of HLL include
BASIC, JAVA, PASCAL, FORTRAN, C, C++, ALGOL, etc.

FEATURES OF HIGH LEVEL LANGUAGES


Most of the HLL have common features with little differences here and there. The general
features include:
1. It is machine independent
2. It is a compilation of symbols, words and sentences
3. It is problem oriented and user friendly
4. It comprises of set of rules that must be obeyed
5. It has to be translated into machine code
6. It is easy to develop and easy to debug.

FEATURES OF BASIC
 Easy to learn to learn for beginners
 Powerful additional features for advanced users
 User friendly and interactive
 Portable
FEATURES OF C
 Portability
 Bit manipulation
 Modula programming facility (programs are in modules)
 User friendly design
 Efficient use of pointers
FEATURES OF PASCAL
Built – in data types
User defined data types
Built – in data structures
Strong data type diagnosing element
Structured programming support

CLASSIFICATION OF HLL BASED ON APPLICATIONS


High level languages can be classified based on their uses as follows:
1. SCIENTIFIC LANGUAGES: These are oriented towards solving mathematical and statistical
problem. They are flexible in handling scientific oriented problems.
EXAMPLES:
BASIC: Beginners All – purpose Symbolic Instruction Code
FORTRAN: Formula Translation
ALGOL: Algorithmic Language
PL1: Programming Language (version 1)
APL: A Programming Language

2. BUSINESS ORIENTED LANGUAGES: They are flexible in handling business oriented


problems. Ie they can handle data / file processing. Eg COBOL: Common Business Oriented
Language, RPG: (Report program Generator), etc.

3. ARTIFICIAL INTELLIGENCE (AI) LANGUAGES: They can manipulate strings, search for
patterns, inserting and deleting characters. Eg LISP (List Processing), PROLOG (Programming
in Logic)

4. OBJECT ORIENTED LANGUAGES: They can create programs into objects and classes eg
C++, JAVA, VB.Net, etc

5.VISUAL PROGRAMMING LANGUAGES: These are languages designed for creating window
based applications e.g. VISUAL BASIC, VISUAL C, VISUAL JAVA

6. GENERAL PURPOSE LANGUAGES: These are languages that fit into many categories. Ie can
solve varieties of problems eg. C, PASCAL

SPECIAL PURPOSE LANGUAGES (SPL): SPL are languages that are used for specified
applications e.g. SNOBOL (String Oriented and Symbolic Language)

ADVANTAGES OF HLL OVER ML AND LLL


HLL are not machine dependent
HLL are problem oriented
They resemble natural human language, unlike the LLL and ML that are binary and
Mnemonic codes respectively
They use mathematical notations and symbols
They have and utilize a built in library of functions

ASSIGNMENT
State the major/ common features of a high Level language
State the advantages of HLL over ML and LLL
INSTRUCTIONAL MATERIAL
OBJECTIVES PRACTICE QUESTIONS

Question 1

Which of the following correctly describes an array?

A. A variable that can store multiple data types


B. A collection of elements of the same type stored in contiguous memory locations
C. A collection of elements that can vary in type and size dynamically
D. A function that stores values and performs arithmetic operations

Answer: B. A collection of elements of the same type stored in contiguous memory locations

Explanation: Arrays are data structures that store elements of the same type in contiguous
memory locations, allowing efficient access using indices.

Question 2

If int arr[5] = {3, 7, 2, 9, 4};, what is the value of arr[2]?

A. 3
B. 7
C. 2
D. 9

Answer: C. 2

Explanation: Array indices start at 0, so arr[2] refers to the third element in the array,
which is 2.

Question 3
What will be the output of the following code snippet?

python
Copy code
arr = [1, 2, 3, 4, 5]
print(arr[1] + arr[3])

A. 3
B. 5
C. 6
D. 6

Answer: D. 6

Explanation: arr[1] is 2, and arr[3] is 4. Their sum is 2 + 4 = 6.

Question 4

What does the following code do in an array arr of size 5?

python
Copy code
for i in range(5):
arr[i] = i * 2

A. Assigns the value of i + 2 to each element


B. Doubles each value in the array
C. Stores the square of each index in each element
D. Stores double the value of each index in each element

Answer: D. Stores double the value of each index in each element

Explanation: The code assigns i * 2 to each element in the array, so each element stores
twice the index value.

Question 5

Which statement about arrays is incorrect?

A. Arrays can store multiple data types.


B. Array elements are accessed using an index.
C. Arrays have a fixed size in most programming languages.
D. The first element of an array has index 0.

Answer: A. Arrays can store multiple data types.

Explanation: Arrays store elements of a single data type.

You might also like