0% found this document useful (0 votes)
4 views

BASIC Statements and Arrays Group 6

Uploaded by

gideon.aleburu
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)
4 views

BASIC Statements and Arrays Group 6

Uploaded by

gideon.aleburu
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

Title Page

TOPIC: BASIC Statements and Arrays

GROUP: Group 6​

COURSE CODE: CSC 111​

COURSE TITLE: Introduction to Essential Programming Language

NAMES AND MATRIX NUMBERS:

●​ Obasi Precious Oluchi ​


MATRIC NUMBER: EDU2412554​

●​ Bamidele Mufuliat Abidemi​


MATRIC NUMBER: EDU2412552
Table of Contents
●​ Introduction to BASIC Programming​

●​ BASIC Statements Introduction​

●​ Common BASIC Statements​

●​ Control Flow in BASIC​

●​ Introduction to Arrays in BASIC​

●​ Using Arrays in BASIC​

●​ Combining Statements and Arrays​

●​ Conclusion and References​


Introduction to BASIC Programming​

Brief History of BASIC: BASIC stands for Beginner's All-purpose Symbolic Instruction
Code. It was developed in 1964 by John G. Kemeny and Thomas E. Kurtz at Dartmouth
College in the United States.

At that time, most programming languages were complex and difficult to learn, especially for
students who were not studying mathematics or engineering. Kemeny and Kurtz wanted to create
a language that would make programming easier and more accessible to beginners, especially
students in other fields.

BASIC was originally created to run on Dartmouth’s time-sharing computer system, allowing
multiple users to write and run programs simultaneously. It became one of the most popular
programming languages in the 1970s and 1980s, especially with the rise of personal computers
like the Apple II and early Microsoft systems.

As computers became more widespread, BASIC helped millions of people take their first steps
into programming.

Why Was BASIC Created? BASIC was created to make computer programming simple and
accessible to beginners—especially students who were not majoring in science, technology,
engineering, or mathematics.

Before BASIC, programming required knowledge of complex languages like FORTRAN or


assembly language, which were difficult for non-technical users to learn. Professors John G.
Kemeny and Thomas E. Kurtz wanted to change that​

In short, BASIC was created to democratize programming, making it something anyone could
learn—not just professional programmers.

Relevance and Usage Today: BASIC remains relevant in Nigerian education today, especially in
secondary schools and introductory computer science courses, because of its simplicity and
effectiveness in teaching programming fundamentals. It is part of the curriculum approved by
examination bodies like WAEC and NECO, making it a common starting point for students
learning to code. It's easy-to-understand syntax helps beginners grasp key programming concepts
such as variables, loops, and conditional statements. Additionally, BASIC runs well on low-spec
computers, which is ideal for many Nigerian schools with limited resources. Overall, BASIC
continues to play an important role in building logical thinking and foundational coding skills
among students.​
BASIC Statements Introduction​

What Are Statements?

BASIC statements are the individual instructions that tell the computer what actions to perform
in a BASIC program. Each statement is written on a separate line (usually with a line number)
and serves a specific purpose such as displaying output, taking input, making decisions, or
repeating tasks. They form the building blocks of every BASIC program.

Types of Statements in BASIC​


In BASIC programming, statements can be categorized into different types based on their
function. Here are the main types:

●​ Evaluating Statements

These are used to perform calculations or assign values to variables. They are fundamental for
setting up data in the program, e.g., LET A = 5+2

●​ Executable Statements

These statements cause the program to perform a specific action, such as printing output, jumping
to another line, or ending the program. Actions like PRINT or GOTO.

●​ Input/Output Statements

These statements allow interaction between the program and the user. Read or display data, e.g.,
INPUT, PRINT
Common BASIC Statements​

●​ PRINT – Displays text or values. Example: 10 PRINT "Hello"​

●​ INPUT – Gets input from the user. Example: 20 INPUT A​

●​ LET – Assigns values. Example: 30 LET B = A + 10​

●​ IF…THEN – Conditional execution. Example: 40 IF B > 10 THEN PRINT "Large"​

●​ GOTO – Jumps to another line. Example: 50 GOTO 10​

●​ END – Ends the program. Example: 60 END

Short Example Program:

10 INPUT A

20 LET B = A * 2

30 PRINT "Double is", B

40 END
Control Flow in BASIC
Conditional Statements:

●​ IF…THEN: Check the condition.​


Syntax:-IF condition THEN command​
Example:- IF A > 10 THEN PRINT "A is greater than 10"​

●​ IF…THEN…ELSE (in some BASIC versions): Chooses between two actions.​


Syntax: IF condition THEN command1 ELSE command2​
Example: IF A > 10 THEN PRINT "A is greater than 10" ELSE PRINT "A is 10 or less"

Looping Statements:

●​ FOR…NEXT – Repeats a block of code a fixed number of times.​


Syntax: ​
FOR I = start TO end​
command​
NEXT I​
Example:​
FOR I = 1 TO 5​
PRINT I​
NEXT I
●​ WHILE – Repeats while a condition is true (in some BASIC variants).​
Syntax: ​
WHILE condition​
command​
WEND​
Example:​
WHILE A < 10​
LET A = A + 1​
WEND
●​ DO UNTIL – Repeats until a condition becomes true (in newer BASIC).​
Syntax: ​
DO​
command​
LOOP UNTIL condition​
Example: ​
DO​
LET A = A + 1​
LOOP UNTIL A = 10
Introduction to Arrays in BASIC
What Is an Array?

An array is a data structure that allows you to store multiple values in a single variable. Instead
of creating individual variables for each piece of data, an array lets you group them together.

Declaring Arrays:

In BASIC, declaring an array involves specifying the name of the array and the number of
elements (size) it will contain. The DIM statement is used to declare arrays.

Example: 10 DIM A(10) – creates space for 11 elements (0 to 10)

Types of Arrays:

One-Dimensional (1D) Arrays:

A single list of values.

Example:​
DIM A(5) – This creates an array with 5 elements.

Two-Dimensional (2D) Arrays:

A table of values with rows and columns.

Example:

DIM A(3, 3) – This creates a 3x3 matrix of values, where you can access each element using two
indices, like A(1,1) for the value in the first row and first column.

Syntax:

DIM A(10) – Declares a 1D array with 11 elements.


Using Arrays in BASIC
Storing Values in Arrays:

Example: 10 LET A(2) = 5

Accessing Elements:

PRINT A(2) – Displays 5

Iterating Through Arrays With Loops:

Example Program:

10 DIM A(5)

20 FOR I = 1 TO 5

30 INPUT A(I)

40 NEXT I

50 FOR I = 1 TO 5

60 PRINT A(I)

70 NEXT I

Why Use Arrays?

●​ Efficient Data Management: Arrays allow you to handle large amounts of data without
creating numerous individual variables.​

●​ Easy Access to Data: You can easily access or modify values using their index.​

●​ Compact Code: Arrays make your code more compact and organized, especially when
dealing with related data.​

In summary, arrays are powerful tools for storing and organizing multiple pieces of data in
programming, making it easier to work with large datasets.
Combining Statements and Arrays
Building a Small Application:

Case Study – Student Scores and Averages.

10 DIM SCORES(5) ' Declare an array with 5 elements

20 FOR I = 1 TO 5

30 INPUT SCORES(I)

40 NEXT I

50 SUM = 0

60 FOR I = 1 TO 5

70 LET SUM = SUM + SCORES(I)

80 NEXT I

90 LET AVG = SUM / 5

100 PRINT "Average Score is ", AVG

110 END


Conclusion and References
Importance of Learning BASIC:

Learning BASIC is important in Nigerian education because it provides a foundational


understanding of programming concepts that are essential for students to develop
problem-solving and critical-thinking skills. As a beginner-friendly language, BASIC helps
students grasp the core principles of coding, logic, and structured thinking, which can be applied
to more advanced programming languages later. Additionally, learning BASIC promotes digital
literacy, which is crucial in today’s technology-driven world, empowering Nigerian students to
participate in the global digital economy and pursue careers in fields like software development,
data analysis, and engineering.

Summary of Key Points:

●​ BASIC is simple and educational.​

●​ BASIC helps learn programming basics.​

●​ Statements control actions, and arrays store data.​

●​ Control flows and loops make programs interactive.​

Sources Used:

●​ Lecture notes from CSC 111 – Introduction to Essential Programming Language.​

●​ https://nou.edu.ng/coursewarecontent/CIT%20132.pdf?utm​

●​ Computer Studies for Nigerian Secondary Schools – Macmillan.​

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy