Professional Documents
Culture Documents
CSC 102 Materials
CSC 102 Materials
A TUTORIAL GUIDE
TO
CSC 102
BALOGUN, T. R
(a.k.a. B. PROGRAMMER)
COURSE OUTLINE
1
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
What is Computer?
The basic function of the computer can be represented as in figure 1.1 below
INPUT PROCESS OUTPUT
(1) Input: this is the entry point to a computer where data is fed into it
for processing, i.e. computer accepts input data
(2) Process: this is the operation of converting data (raw fact) read into
the computer into a finished and meaningful product (information) i.e.
a program or instruction in execution
(3) Output: this is the terminal point where information is being
produced i.e. computer generates information as output.
The benefit derived from the computer can be attributed to the following:
2
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
Types of Computer
Basically there are two types of computer namely; analogue computer and
digital computer. The comparison between the two is hereby presented in a
tabular form below;
When a computer makes use of both analogue and digital components and
techniques; it is called HYBRID COMPUTER. Such a computer requires Analogue-
to-Digital and Digital-to- Analogue converters; which would make analogue data
acceptable to a digital computer & vice versa.
3
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
4
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
6
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
7
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
What is a program?
What is programming?
Who is a Programmer?
Low-level language
8
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
9
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
Syntax error
Semantic error
10
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
1. SYNTAX ERROR
This is an error caused due to violating the syntax rule of the language.
This error can be identified by the translator (computer or interpreter),
which halt the execution of the program.
2. SEMANTIC ERROR
ALGORITHM DESIGN
WHAT IS AN ALGORITHM?
COMPONENTS OF ALGORITHM
I. SEQUENCE
II. SELECTION and,
III. ITERATION
SEQUENCE: This involves specification of steps of statements or
methods in a specific order i.e. every step of methods is written in
order they will be executed.
11
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
I. PSEUDOCODE
II. FLOWCHART
PSEUDOCODE: This is an English-like representation of an algorithm.
Pseudocode cannot actually run on computer because it is not an
actual computer programming language, rather it merely provide a
convenient method that will assist programmer to “think out” a
program before attempting to write it in a particular programming
language.
EXAMPLES:
Step 5: exit.
Area = 𝜋r2
Step 5: Stop
A=1/2bh
12
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
I. Systems flowchart
II. Program flowchart
14
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
EXAMPLES:
START
ENTER a,b
C=a+b
Print c
STOP
Start
Pie= 3.142
Read r
A = pie*r^2
Print A
stop
15
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
Input b, h
A=1/2*b*h
Print A
Stop
Start
Read A, B
No
Is A > B?
Yes
Print B
Print A
Stop
16
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
Start
Count = 1, Sum =
0
No
Is count
<= 100?
Yes
Count = count + 1
Stop
17
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
WHAT IS BASIC?
BASIC stands for Beginner All-Purpose Symbolic Instruction Code; BASIC was
regarded as a programming language which was developed in 1964 at Dortmouth
College, USA by professors John Kemeny and Thomas E. Kurtz in order to teach
beginner the construction of programming theory. It is used to solve problems
covering a wide range of applications on many different type of digital computer.
Also used for users who are not well-trained programmers.
I.
Numbers/digits (0-9)
II.
Alphabets/letters (A-Z, a-z)
III.
Decimal point (.)
IV.Blank character
V.Grouping characters e.g. colon, semi-colon, comma, single and double
quotes/apostrophe, and parenthesis.
VI. Arithmetic operators e.g.=,+,*,-,/,^,\
VII. Comparison operators e.g. =,<,>,<=,>=,<>
18
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
Data types refer to the type of value that a particular data represent. Data in
BASIC can be classified into two types:
What is a variable?
19
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
What is a constant?
1. Length
2. Breadth
3. A102
4. Sum2
5. Volume_Of_Sphere
20
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
NOTE: Expression within parenthesis, function are evaluated first before any other
operation is carried out.
EXAMPLES
a. Xy+z - x * y + z
b. 4y/27-5c/x - 4 * y / 27 – 5 * c / x
c. –b+√ (b2-4ac) - -b + (b ^ 2 – 4 * a * c) ^ 0.5
d. S=ut+1/2at2 - s = u * t – 1 / 2 * a * t ^ 2
2. Evaluate the following expression given that x=2, y=3, z=5, b=10, a=4, c=4
a. Xy+z
b. 4y/3-5c/x
c. –b+√ (b2-4ac)
a. Xy+z - x * y + z = 2 * 3 + 5 = 6 + 5 = 11
b. 4y/3-5c/x -4 * y / 3 – 5 * c / x = 4 * 3 / 3 – 5 * 4 / 2 = 4 – 10 = -6
c. –b+√ (b2-4ac) - -b + (b ^ 2 – 4 * a * c) ^ 0.5 = -10 + (10 ^ 2 – 4 * 4 * 4) ^
0.5 = -10 + (100 -64) ^ 0.5 = -4
21
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
RELATIONAL OPERATORS
The following relational operators are used in testing a relation between two
entities
LOGICAL OPERATOR
These are based on conditional statements which are either true or false. We have
the following logical operators:
-AND logical AND indicate that logical expression X AND Y, is true (T) if and
only if X is true and Y is true
-OR (inclusive OR) indicate that logical expression X OR Y is true (T), if either X
is true OR Y is true or both
-XOR (exclusive OR) indicate that logical expression X XOR Y is true if either X
is true or Y is true, but not both
-NOT (logical operator NOT) indicates the negation or the reverse of a truth
value, i.e. NOT Y is true if Y is false, and false is Y is true.
These are system pre-coded routine, which are normally built as part of the
language interpreter/compiler available in its library: common built in functions
that are for solving mathematical problems are as follows:
LEN (TEXT): return the length of string Text in terms of the number of
data has the string. for example: LET A$= “God Morning”
LEFT (TEXT, SIZE): use to get the out string of the leftmost number of
the character of a string argument: for example:
VAL: The val function returns the numerical value of string of digit.
For example:
23
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
ASC: This return the equivalent ASCII value of any given character for
example:
BASIC STATEMENTS
Examples:
Examples:
24
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
Nn Identifier= expression/values/variable
Examples:
PRINT Statement: This is to display output data items on the screen of the
monitor/VDU at the point of execution of the written program.
Examples:
END Statements: this statement mark the terminating point for the
program. No executable statements should follow this statement since
execution of the main program ends at this statement.
Syntax: nn END
Examples:
I. 100 END
II. END
Syntax: nn STOP
25
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
Examples:
I. 20 STOP
II. STOP
Examples:
Examples:
BOURNVITA #600.00
GOLDEN MORN #450.00
READ and DATA Statement: These two statements are used in pair to
allow input data items to be used in program. Unlike INPUT statement,
READ and DATA statement not only allow specification of variable-list or
data-item with READ but also gives room for the provision of the
corresponding data values for each of the specified variables indicated by
READ using the DATA statement written to form part of the source code.
26
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
Example:
I. 10 READ A,B,C,D
SOLUTION
30 END
SOLUTION
30 END
SOLUTION:
30 INPUT R
40 LET V = 4 / 3 * PIE * R ^ 3
27
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
50 PRINT V
60 END
LET A = 1 / 2 * (a + b) * h
END
END
28
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
Statements
END IF
PRINT “A is greater”
END IF
NB: from the example above, the statement PRINT “A is greater” will be
executed only if value of A is greater than B and nothing happens
otherwise.
Statement A
ELSE
Statements B
END IF
29
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
PRINT “A is greater“
ELSE
PRINT “B is greater”
END IF
NB: from the expression above, the statement PRINT”A is greater” will be
executed only if value A is greater than B, but if A is not greater than B,
this cause the statement PRINT “B greater than A” to be executed.
Statement 1
Statement 2
Statements N
ELSE
Statement N+1
END IF
Example: assuming we are given a table of score grade for CSC 102 as
represented below:
70-100 A 5
60-69 B 4
50-59 C 3
45-49 D 2
30
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
40-44 E 1
BELOW 40 F 0
And we are about to design a BASIC program to generate the Grade and
Print for a student.
REM PROGRAM to test for score and generate grade, point for a
student
ELSE
LET POINT= 0
END IF
END
NB: this program above will allow any value between 0 and 100 to be read and
placed in variable score, test the value of score against the values specified in each
condition if the IF—THEN—ELSEIF statement, then once any of the condition
31
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
evaluated to be true then the statement within that block IF will be executed
immediately; i.e. assuming we are given that score = 53, this will allow the
program to generate as output:
Grade is: C
Point is: 3
Since the condition: “score>=50 AND score<=59” will be the only one to
evaluate to be true as the given score (53) lies between 50 and 59.
Example:
END
NB: The above program will allow value to read into I, the value of I will be use
to divide by 2, then the integer remainder resulting from this division
process will be tested against zero, once there is a match then the input will
be: “I is an EVEN number”.
MOD: Integer Remainder Operator used to perform division and return any
whole number indicating the number i.e.
I MOD 2= I - (I \ 2) * 2
IF I = 15, then
15 MOD 2= 15 - (15 \ 2) * 2 = 5 – 7 * 2 = 15 – 14 = 1
Therefore 15 MOD 2 = 1
32
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
Example: 30 GOTO 70
70 END
NB: you should try to avoid unnecessary use of this statement has this can
cause indefinite/infinite execution of the program without end (i.e. endless
program execution): which in turn result into damage/harm the processor
and the memory of the system.
CASE VALUE 1
Statements1
CASE Value 2
Statement 2
CASE Value n
Statement n
CASE ELSE
Statement n+1
END SELECT
33
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
INPUT TEMP
CASE 1
PRINT “HOT”
CASE 2
PRINT “WARM”
CASE 3
PRINT “COLD”
CASE 4
END SELECT
END
Statement
34
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
NB: for the execution to occur within the body of the FOR-NEXT loop, the initial
value must be less than or equal to final value (i.e. initial value <= final
value), with a STEP of increment value (i.e. positive whole number), Also,
when the initial value greater than the final value (i.e. initial value > final
value), there must be decrement (i.e. negative whole number) specified for
the STEP.
Besides, if there is no value specify for the STEP, the computer will
assume a default of value one or 1 for the STEP as an increment for the
execution to occur.
Examples:
FOR I = 1 TO 100
PRINT I
NEXT I
END
ii. write a BASIC program to generate odd numbers and compute their sum
between 1 and 1000
LET SUM = 0
PRINT I
NEXT I
PRINT SUM
END
35
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
Syntax: WHILE
Statements
WEND
Example:
LET SUM = 0
LET I = 2
PRINT I
LET I = I + 2
WEND
PRINT SUM
END
Statements
LOOP
NB: condition is tested before the execution of the statement in the body
of this loop. Also, execution may not take place if the condition is not
satisfied.
Examples:
36
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
LET PRODUCT = 1
LET I= 1
PRINT I
LET I = I + 2
LOOP
PRINT PRODUCT
END
Syntax: DO
Statements
NB: condition is tested after the execution of the statements that form
the body of the loop. Also, execution of statement will take place at least
once.
Examples:
37
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
LET PRODUCT = 1
LET I = 1
DO
PRINT I
LET I = I + 2
END
LET PRODUCT = 1
LET I = 2
DO
PRINT I
LET I = I + 2
END
ARRAY
An array is a vector variable that holds a set of values at a time. Arrays can
be referred to as a collection of elements/data items of the same type recognised,
and identified by a name. Besides, an array can also be viewed as a table
containing a set of elements grouped into rows and columns.
38
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
2 4 5 7 6 21
15
-1
50
74
e.g.
2 4 54 32 667 331
13 -33 44 21 44 53
The element in an array is refer to by the array name , with the subscript
or index position of this element enclosed in parenthesis for example:
given a table of numbers as follows:
2 4 7 3 20
39
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
TABLE A
To refer to the 2nd and 4th elements in the table above we say:
Example:
1. Write a BASIC program that compute the sum and average (mean) of N
numbers
(HINT: 1≤ N ≤ 500)
DIM X(500)
LET SUM = 0
FOR I = I TO N
40
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
INPUT X (I)
NEXT I
ELSE
END IF
END
FOR I = 1 TO 3
FOR J = 1 TO 3
NEXT J
NEXT I
FOR I = 1 TO 3
FOR J= 1 TO 3
NEXT J
NEXT I
FOR I = 1 TO 3
FOR J = 1 TO 3
PRINT C(I,J)
NEXT J
NEXT I
END
42
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
o MS-DOS COMMANDS
MS-DOS indicates the command line by displaying the command prompt. For
example: C:\> you type command at this prompt to specify the task you want to
perform. For example, type Ver then press the enter key; then MS-DOS version
number would be displayed.
PARTS OF COMMAND
I. THE COMMAND NAME: this specifies the action you want MS-DOS to
carry out. For example: DEL, COPY, CLS
II. PARAMETERS: this defines the object you want MS-DOS to act on. For
example, the Del(Erase) command requires a parameter that is name of
the file you want to delete. i.e. Del CSC102.txt
III. SWITCH: is a forward slash (/) usually followed by a letter o number
If you want to stop MS-DOS from completing a command; press ctrl + break + C.
Your command is cancelled and the command prompt appears.
The current drive appears as the first letter of the command prompt. On most
system if the letter is A or B, one of the floppy disk drive (51/4 or 31/2) is the
current drive.
To change the current drive, type the letter of the drive followed by a colon.
For example,
TYPES OF COMMAND
1. INTERNAL COMMAND: these are commands loaded into memory, when
you start your system and are placed in a file called COMMAND.COM.
Examples are: Dir, Del, Date, Time and so on.
43
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
CLS (clear screen): this is use to clear the screen of the MS-DOS, so that it will
only display command prompt and cursor. E.g. type the cls at the command
prompt i.e.
Syntax:
i. CD.. : specifies that you want to change the immediate parent directory of
the current directory or subdirectory.
ii. CD\ : specifies that you want to change the current drive or switch to
command prompt, with no directory i.e. to have a direct access to the
content of the drive but not its content directories.
iii. CD Drive: paths : specifies the drive and directory you wish to switch to.
Examples:
COPY: use to copy one or more files from one location (drive or directory) to
another
44
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
SOURCE: specifies the location and the name of files from which you want
to copy. It may contain drive letter, colon followed by directory name or
filename
DESTINATION: specifies the location and name of files to which you want to
copy. It may consist drive letter, colon, followed by pathname (directory
name or filename or combination)
Examples:
This will allow all the files placed directly on drive C to move to a directory
name “All_files” on drive C
II. C:\> COPY C:\*.* A:\All_enteries (type and press the enter key)
This will move all the file placed/stored directly on drive C to a directory called
“All entries” on drive A.
III. C:\> COPY C:\BASIC\sample1.BAS C:\CSC 102 (type and press the enter
key)
This copy a title called ”sample1.BAS”from the directory named “BASIC” on
drive C to a directory called “CSC 102” in drive C
IV. C:\> COPY C:\BASIC\*.BAS C:\CSC102 (type and press the enter key)
This will move all the file with an extension .BAS from a directory called
“BASIC” on drive C to a directory known as “CSC 102” on drive C.
DIR: use to display a list of all files, directories or subdirectories that are in
the drive or directory specified.
Syntax: DIR or
Examples:
This display all file, directories and subdirectories in the drive C. The list
items may include the disk’s volume label, serial number, directory or file
name per line, the file size in bytes, the date and time the file last modified,
45
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
total number of files; their commutative size, the free space (in byte)
remaining on the disk.
II. C:\> DIR C:\BASIC\*.BAS /W/P (type and press enter key)
This display in wide format a list of only file name of files with extension
“.BAS” in directory “BASIC”, and pause each time the screen fills until you
press enter key to continue.
/P: causes the directory (Dir) to display only to pause once the screen is
filled.
/W: to select a wide display and cause DOS to display only filenames with
no other information.
XCOPY: copies directories, their subdirectories, and files (except hidden and
system files).
Examples:
This copy the content of disk drive A and placed it disk drive C
Examples:
i. C:\> DEL CSC 102.txt- this delete the files called CSC102.txt from
disk on drive C
ii. C:\> DEL C:\test\CSC102.tmp- this deletes files: “CSC102.tmp” from
directory “test “on drive C
CHKDSK: check the status of a disk and display a status report such as
number of spaces used and free for use, check for error in disk.
46
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
FORMAT: specify to prepare or repair the disk for use. The FORMAT
command creates a new root directory and file allocation table for the disk.
It can also check for bad areas on the disk, and also delete all the data on
the disk.
This will delete (remove) a directory named CSC102 from disk drive C.
TIME: displays the system time or set your computer internal clock.
Example:
i. Just type TIME at the command prompt as in C:\> TIME, then press
enter key; eventually display the system time.
47
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
DATE: to display the system date and set your computer date.
Syntax: DATE (date format)
Example:
i. C:\> DATE (type and press enter key)
48
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
Visual basic provides the tools you need to create windows with familiar elements
like menus, text boxes, command button, option buttons, check boxes, etc.
Microsoft Windows uses a Graphical Users Interface (GUI).
TERMINOLOGIES IN VB
1. DESIGN TIME: this is the time at which VB application is being developed.
2. BREAK TIME: this is the time when there is a pause in the execution of the
VB program.
3. RUN TIME: this is the time at which VB application developed is being
executed and tested.
4. FORM: this is a small windows or dialog representing a user interface on
which control are added in order to develop a VB application.
5. CONTROL: these are element or graphical representation of an object added
to a form in order to create VB application. Examples are: labels, textboxes,
checkboxes, option buttons, combo boxes, command buttons etc.
6. OBJECT: this is the name used to refer combination of form and control
that make up the VB application.
7. PROPERTIES: these refer to attribute or behaviour or appearance of an
object. Examples are: Name, text, caption, back color, font, visible etc. We
can refer to a property of an object in a VB procedure as:
objectname.property= value e.g. text1.text = “welcome!”
8. METHOD: this refers to the action performed on object or action performed
by an object. Examples are: print, resize, show, hide, load, unload etc. we
can refer to a method of an object in a VB code as: Object name. E.g.
picture1.print “welcome to FUTA”
49
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
9. EVENT: These refer to what happen to an object when a user interacts with
the designed VB application. Examples are: click, load, activate, unload, key
press, mouse down, lost focus etc.
Objectname_event
VERSIONS OF VB
Microsoft Visual BASIC for windows comes in a working model, a learning
edition, a professional edition. Anyone planning to do professional
application development that includes the advanced features of database
management should use the professional edition, enterprise edition, or
express edition with .NET framework facilities.
INTRODUCING VB CONTROLS:
I. TEXT BOXES: we do use a text box control when we want the user to type
some input, to allow user to modify the content of any information or
message, to create a text editor window, and to display an editable report.
Some commonly used properties of text box are: text, name, alignment, font,
50
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
multi line, maxlength etc. the 3 – letter prefix for naming a textbox is “txt”.
E.g. txtlenght
II. LABEL: we use a label control when we want the user to view some output,
to label; or name other control on form, to display any information whose
content cannot be modified, to generate non-editable report. Some common
properties of label are: caption, name, font, backcolor, alignment etc.
The 3- letter prefix for naming a label is “lbl” e.g lblarea
III. FRAMES: frames are used as containers for other controls. Usually, group o
option buttons or check boxes are placed in frames. Using frames to group
controls make your forms easier to understand. Some common properties
include; caption, name etc. the 3- letter prefix for naming a frame is “fra”.
E.g. fracolor.
IV. CHECKBOXES: check boxes allow the user to select (or deselect) an option.
In any group of checkboxes, any number of them may be selected. The value
properties of a checkbox are set to 0 if unchecked, 1 if checked, 2 if greyed
(disabled).
V. OPTION BUTTONS: use option button when only one button of a group may
be selected. Any option buttons placed directly on the form (not in a frame)
function as group. A group of option buttons inside a frame function
together. The best method is to first create a frame and then create each
opton button inside the frame. The value property of an option button is set
to true if selected or if unselected. The3 –letter prefix for naming an option
button is “opt” e.g. optred.
51
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
1. CLS
REM PROGRAM TO COMPUTE THE FACTORIAL OF N POSITIVE INTEGERS
LET FACT = 1
INPUT “ENTER ANY POSITIVE INTEGER N: ”; N
IF(N < 0) THEN
PRINT “INVALID INPUT! ENSURE YOU ENTER A POSITIVE NUMBER”
ELSE
FOR I = N TO 1 STEP -1
LET FACT = FACT * I
NEXT I
PRINT “FACTORIAL OF ”; N; “=”;FACT
ENDIF
END
2. CLS
REM PROGRAM TO COMPUTE THE ROOTS OF A QUADRATIC EQUATION USING ‘QUADRATIC FORMULAE
INPUT “ENTER VALUE FOR A”; A
INPUT “ENTER VALUE FOR B”; B
INPUT “ENTER VALUE FOR C”; C
LET D = B ^ 2 – (4 * A * C)
IF (D < 0) THEN
PRINT “COMPLEX ROOTS”
ELSEIF(D = 0)THEN
LET X1 = -B /(2 * A)
PRINT “EQUAL ROOTS:”;X1
ELSE
LET X1 = (-B + SQR(B ^ 2 – 4 * A * C))/(2 * A)
LET X1 = (-B - SQR(B ^ 2 – 4 * A * C))/(2 * A)
PRINT “ROOT1 =”; X1; “ROOT2 =”; X2
ENDIF
END
3. CLS
REM PROGRAM TO COMPUTE THE SUM OF THE SQUARE OF N NUMBERS
LET SUMSQ = 0
INPUT “ENTER ANY POSITIVE INTEGER N:”; N
FOR I = 1 TO N
LET SUMSQ = SUMSQ + (I ^ 2)
NEXT I
PRINT “THE SUM OF THE SQUARE OF N NUMBERS:”; SUMSQ
END
4. CLS
REM PROGRAM TO GENERATE EVEN NUMBERS BETWEEN 1 AND 100 AND THEIR SUM
LET SUMEVEN = 0
PRINT “EVEN NUMBERS”
FOR I = 2 TO 100 STEP 2
PRINT I
LET SUMEVEN = SUMEVEN + I
NEXT I
PRINT “SUM OF EVEN NUMBERS BETWEEN 1 AND 100 IS”; SUMEVEN
END
5. CLS
REM PROGRAM TO GENERATE EVEN NUMBERS BETWEEN 1 AND 100 AND THEIR PRODUCTS
LET PRDTEVEN = 1
PRINT “EVEN NUMBERS”
FOR I = 2 TO 100 STEP 2
52
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
PRINT I
LET PRDTEVEN = PRDTEVEN * I
NEXT I
PRINT “PRODUCT OF EVEN NUMBERS BETWEEN 1 AND 100 IS”; PRDTEVEN
END
6. CLS
REM PROGRAM TO GENERATE ODD NUMBERS BETWEEN 1 AND 100 AND THEIR SUM
LET SUMODD = 0
PRINT “ODD NUMBERS”
FOR I = 1 TO 100 STEP 2
PRINT I
LET SUMODD = SUMODD + I
NEXT I
PRINT “SUM OF ODD NUMBERS BETWEEN 1 AND 100 IS”; SUMODD
END
7. CLS
REM PROGRAM TO GENERATE ODD NUMBERS BETWEEN 1 AND 100 AND THEIR PRODUCTS
LET PRDTODD = 1
PRINT “ODD NUMBERS”
FOR I = 1 TO 100 STEP 2
PRINT I
LET PRDTODD = PRDTODD * I
NEXT I
PRINT “PRODUCT OF ODD NUMBERS BETWEEN 1 AND 100 IS”; PRDTODD
END
8. CLS
REM PROGRAM TO GENERATE SUM OF ALL EVEN NUMBERS, SUM OF THE SQUARE OF EVEN NUMBERS,
REM AND PRODUCT OF THE SUM OF THE SQUARE AND SUM OF ALL EVEN BETWEEN 1 AND 100
LET SUM = 0
LET SUMSQ = 0
PRINT “EVEN NUMBERS”; “SQUARE OF EVEN NUMBERS”
FOR I = 2 TO 100 STEP 2
PRINT I, I ^ 2
LET SUM = SUM + I
LET SUMSQ = SUMSQ + (I ^ 2)
NEXT I
LET PRODUCT = SUM * SUMSQ
PRINT “THE SUM OF ALL EVEN NUMBERS BETWEEN 1 AND 100 =”; SUM
PRINT “THE SUM OF THE SQUARE OF EVEN NUMBERS BETWEEN 1 AND 100 =”; SUMSQ
PRINT “THE PRODUCT OF SUMS OF ALL EVEN NUMBERS BETWEEN 1 AND 100 =”; PRODUCT
END
9. CLS
REM PROGRAM TO CONVERT DOLLARS TO NAIRA IF 1 DOLLAR = 200 NAIRA
INPUT “ENTER THE AMOUNT IN DOLLARS:”; AMT
LET NAMT = AMT * 200
PRINT AMT; “IN DOLLAR IS”; NAMT; “NAIRA”
END
10.
CLS
REM PROGRAM TO ACCEPT A STUDENT SURNAME, MIDDLE NAME, AND FIRST NAME, THEN
REM CONCANTENATE(JOIN) THEM INTO A VARIABLE CALLED NAME
INPUT “READ IN YOUR SURNAME”; SURNAME$
INPUT “READ IN YOUR MIDDLE NAME”; MIDDLENAME$
INPUT “READ IN YOUR FIRST NAME”; FIRSTNAME$
53
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
54
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
16.
CLS
REM PROGRAM TO COMPUTE THE PRODUCT OF MULTIPLE OF A GIVEN INTEGER NUMBER BTW 1 - 100
LET PRODUCT = 1
INPUT “ENTER ANY POSITIVE INTEGER NUMBER N:”; N
PRINT “MULTIPLES OF”; N; “ARE:”
FOR I = 1 TO 100
IF (I MOD N = 0) THEN
PRINT I
LET PRODUCT = PRODUCT * I
ENDIF
NEXT I
PRINT “THE PRODUCT OF THE MULTIPLES OF”; N; “=”; PRODUCT
END
17.
REM PROGRAM TO GENERATE PRIME NUMBERS BETWEEN 1 AND 100
PRINT “PRIME NUMBERS ARE:”
FOR I = 2 TO 100
FOR J = 2 TO I-1
IF (I MOD J = 0) THEN 60
NEXT J
PRINT I
60 NEXT I
END
55
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
18.
CLS
REM PROGRAM TO GENERATE PRIME NUMBERS BETWEEN 1 AND 100 AND THEIR SUM
LET SUM = 0
PRINT “PRIME NUMBERS ARE:”
FOR I = 2 TO 100
FOR J = 2 TO I-1
IF (I MOD J = 0) THEN 60
NEXT J
PRINT I
LET SUM = SUM + I
60 NEXT I
PRINT “THE SUM OF ALL PRIME NUMBERS BTW 1 AND 100 =”; SUM
END
19.
CLS
REM PROGRAM TO GENERATE PRIME NUMBERS BETWEEN 1 AND 100 AND THEIR PRODUCT
LET PRODUCT = 1
PRINT “PRIME NUMBERS ARE:”
FOR I = 2 TO 100
FOR J = 2 TO I-1
IF (I MOD J = 0) THEN 60
NEXT J
PRINT I
LET PRODUCT = PRODUCT * I
60 NEXT I
PRINT “THE PRODUCT OF ALL PRIME NUMBERS BTW 1 AND 100 =”; PRODUCT
END
20. SOLUTION TO ACTIVITY 4-1(PG. 38) IN THE PRACTICAL MANUAL
CLS
REM PROGRAM TO DETERMINE WHETHER AN INTEGER NUMBER IS A PRIME OR COMPOSITE NUMBER
INPUT “READ IN ANY INTEGER NUMBER N:”; N
IF (N <= 1) THEN
PRINT “NUMBER MUST BE POSITIVE!”
ELSE
FOR J = 2 TO N-1
IF (N MOD J = 0) THEN 70
NEXT J
PRINT N; “IS A PRIME NUMBER”
GOTO 80
ENDIF
70 PRINT N; “IS A COMPOSITE NUMBER”
80 END
21.
CLS
REM PROGRAM TO DETERMINE WHETHER A NUMBER IS ODD NUMBER, EVEN NUMBER, OR PRIME NUMBER
56
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
57
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
24.
CLS
REM PROGRAM TO DETERMINE WHETHER A POSITIVE INTEGER NUMBER IS AN EXCESS/SURPLUS NUMBER
LET SUM = 0
INPUT “ENTER ANY POSITIVE INTEGER N:”; N
FOR I = 1, N-1
IF (N MOD I = 0) THEN
LET SUM = SUM + I
PRINT “FACTOR =”; I
ENDIF
NEXT I
IF (SUM > N) THEN
PRINT N; “IS AN EXCESS NUMBER”
ENDIF
END
25.
CLS
REM PROGRAM TO COMPUTE THE INVERSE/RECIPROCAL OF EVEN NOS BTW 1–30 AND THEIR PRODUCT
LET PRODUCT = 1
FOR I = 2 TO 30 STEP 2
PRINT “INVERSE OF”; I; “=”; 1 / I
LET PRODUCT = PRODUCT * (1 / I)
NEXT I
PRINT “PROUCT OF INVERSE =”; PRODUCT
END
26.
CLS
REM PROGRAM TO DETERMINE EVEN NUMBERS BTW 1-50 THOSE THAT ARE MULTIPLE OF 3
FOR I = 2 TO 50 STEP 2
IF (I MOD 3 = 0) THEN
PRINT I
ENDIF
NEXT I
END
27.
CLS
REM PROGRAM TO GENERATE A FIBONACCI NUMBERS
LET F1 = 1
LET F2 = 1
INPUT “ENTER ANY POSITIVE INTEGER GREATER THAN 2”; N
IF (N < 3) THEN
PRINT F1, F2
ELSE
PRINT F1; F2;
FOR I = 3 TO N
LET FIB = F1 + F2
58
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
LET F1 = F2
LET F2 = FIB
PRINT FIB;
NEXT I
ENDIF
END
28.
CLS
REM PROGRAM TO READ IN A CHARACTER AND DETERMINE WHETHER CHARACTER IS ALPHABET,
REM DIGIT OR SYMBOLIC CHARACTER
INPUT “PRESS IN ANY CHARACTER FROM THE KEYBOARD”; C$
IF ((C$ >= “A” AND C$ <= “Z”) OR (C$ >= “a” AND C$ <= “z”)) THEN
PRINT C$; “IS AN ALPHABET/LETTER”
ELSEIF ((C$ >= “0” AND C$ <= “9”)) THEN
PRINT C$; “IS A DIGIT/NUMBER”
ELSE
PRINT C$; “IS A SYMBOLIC CHARACTER”
ENDIF
END
29.
CLS
REM PROGRAM TO COMPUTE THE SUM AND AVERAGE(MEAN) OF N NUMBERS
DIM X(1000)
LET SUM = 0
INPUT “READ IN ANY POSITIVE INTEGER NUMBER”; N
FOR I = 1 TO N
INPUT X(I)
LET SUM = SUM + X(I)
NEXT I
LET MEAN = SUM / N
PRINT “SUM OF THE GIVEN NUMBERS =”; SUM
PRINT “MEAN (AVERAGE) OF THE GIVEN NUMBERS =”; MEAN
END
30.
CLS
REM PROGRAM THAT COMPUTE THE PERMUTATION OF NUMBERS
LET F1 = 1
LET F2 = 1
INPUT “ENTER ANY POSITIVE INTEGER N:”; N
INPUT “ENTER ANY POSITIVE INTEGER R:”; R
IF (R > N) THEN
PRINT R; “MUST NOT BE GREATER THAN”; R
ELSE
‘TO COMPUTE N FACTORIAL
FOR I = N TO 1 STEP -1
LET F1 = F1 * I
59
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
NEXT I
‘ TO COMPUTE N-R FACTORIAL
FOR J = (N – R) TO 1 STEP -1
LET F2 = F2 * J
NEXT J
LET PERM = F1 / F2
PRINT “PERMUTATION OF NUMBER =”; PERM
ENDIF
END
31.
CLS
REM PROGRAM THAT COMPUTE THE COMBINATION OF NUMBERS
LET F1 = 1
LET F2 = 1
LET F3 = 1
INPUT “ENTER ANY POSITIVE INTEGER N:”; N
INPUT “ENTER ANY POSITIVE INTEGER R:”; R
IF (R > N) THEN
PRINT R; “MUST NOT BE GREATER THAN”; R
ELSE
‘TO COMPUTE N FACTORIAL
FOR I = N TO 1 STEP -1
LET F1 = F1 * I
NEXT I
‘TO COMPUTE N-R FACTORIAL
FOR J = (N – R) TO 1 STEP -1
LET F2 = F2 * J
NEXT J
‘TO COMPUTE R FACTORIAL
FOR K = R TO 1 STEP -1
LET F3 = F3 * K
NEXT K
LET COMB = F1 / (F2 * F3)
PRINT “COMBINATION OF NUMBER =”; COMB
ENDIF
END
32.
CLS
REM PROGRAM THAT GENERATE THE LARGEST (MAXIMUM) OF 10 DIFFERENT NUMBERS
DIM X(10)
PRINT “READ IN 10 DIFFERENT NUMBERS”
FOR I = 1 TO 10
INPUT X(I)
NEXT I
LARGEST = X(1)
FOR I = 2 TO 10
60
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
61
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
35.
CLS
REM TO COMPUTE THE PRODUCT OF 2 X 2 MATRICES A AND B
DIM A(2,2), B(2,2), C(2,2)
PRINT “READ IN ELEMENTS IN MATRIX A:”
FOR I = 1 TO 2
FOR J = 1 TO 2
INPUT A(I,J)
NEXT J
NEXT I
PRINT “READ IN ELEMENTS IN MATRIX B:”
FOR I = 1 TO 2
FOR J = 1 TO 2
INPUT B(I,J)
NEXT J
NEXT I
PRINT “THE PRODUCT OF ELEMENTS IN MATRIX A AND B ARE:”
FOR I = 1 TO 2
FOR J = 1 TO 2
LET C(I,J) = 0
FOR K = 1 TO 2
LET C(I,J) = C(I,J) +(A(I,K) * B(K,J))
NEXT K
PRINT C(I,J),
NEXT J
PRINT
NEXT I
END
36.
CLS
REM PROGRAM TO COMPUTE THE ARITHMETIC MEAN, HARMONIC MEAN, GEOMETRIC MEAN OF 3 NOS
INPUT “ENTER VALUE FOR X:”; X
INPUT “ENTER VALUE FOR Y:”; Y
INPUT “ENTER VALUE FOR Z:”; Z
LET ARITH_MEAN = 1 / 3 * (X + Y + Z)
LET GEOM_MEAN = (X * Y * Z) ^ (1 / 3)
LET HARM_MEAN = 3 / ((1 / X) + (1 / Y) + (1 / Z))
PRINT “THE ARITHMETIC MEAN =”; ARITH_MEAN
PRINT “THE GEOMETRIC MEAN =”; GEOM_MEAN
PRINT “THE HARMONIC MEAN =”; HARM_MEAN
END
37.
CLS
REM PROGRAM TO COMPUTE THE AREA OF TRIANGLE USING HEROES FORMULAE
INPUT “ENTER VALUE FOR A:”; A
INPUT “ENTER VALUE FOR B:”; B
62
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
63
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
NEXT I
LET AVERAGE = SUM / COUNT
PRINT “THE SUM OF ALL THE MULTIPLE OF 5 BTW 1 AND 100 =”; SUM
PRINT “THE AVERAGE OF ALL THE MULTIPLE OF 5 BTW 1 AND 100 =”; AVERAGE
END
42. SOLUTION TO ACTIVITY 5-2(PG. 41) IN THE PRACTICAL MANUAL
CLS
REM PROGRAM TO PRODUCE THE EIGHT TRIPLES OF 0 AND 1 SUCH AS 000, 001, 010,…
FOR I = 0 TO 1
FOR J = 0 TO 1
FOR K = 0 TO 1
PRINT I; J; K
NEXT K
NEXT J
NEXT I
END
43. SOLUTION TO ACTIVITY 5-3(PG. 41) IN THE PRACTICAL MANUAL
CLS
REM PROGRAM TO COMPUTE THE INNER PRODUCT OF VECTOR HAVING 10 COMPONENTS SUCH AS
‘(3,5,4,6,4,3,5,4,3,5) AND (4,4,5,6,7,4,5,4,3,5)
DIM VECTOR1(10), VECTOR2(10)
LET SUM = 0
PRINT “READ IN ELEMENTS OF VECTOR 1:”
FOR I = 1 TO 10
INPUT VECTOR1(I)
NEXT I
PRINT “READ IN ELEMENTS OF VECTOR 2:”
FOR I = 1 TO 10
INPUT VECTOR2(I)
NEXT I
FOR I = 1 TO 10
LET SUM = SUM + (VECTOR1(I) * VECTOR2(I))
NEXT I
PRINT “THE INNER PRODUCT OF 2 VECTORS IS:”; SUM
END
44. SOLUTION TO ACTIVITY 5-5(PG. 41) IN THE PRACTICAL MANUAL
CLS
REM PROGRAM TO SORT A GIVEN SET NUMBERS IN ASCENDING AND DESCENDING ORDER
DIM SET(100)
30 INPUT “READ IN THE NUMBER OF ELEMENTS IN THE SET:”; N
IF(N <= 1 OR N > 100) THEN
PRINT “NUMER MUST BE BETWEEN 2 AND 100: TRY AGAIN WITH CORRECT VALUE”
GOTO 30
ELSE
PRINT “READ IN ALL ELEMENTS IN THE SET:”
64
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
FOR I = 1 TO N
INPUT SET(I)
NEXT I
FOR I = 1 TO N - 1
FOR J = I + 1 TO N
IF(SET(J-1) > SET(J)) THEN
TEMP = SET(J-1)
SET(J-1) = SET(J)
SET(J) = TEMP
ENDIF
NEXT J
NEXT I
PRINT “SET OF NUMBERS IN ASCENDING ORDER IS:”
FOR I = 1 TO N
PRINT SET(I);
NEXT I
PRINT: PRINT “SET OF NUMBERS IN DESCENDING ORDER IS:”
FOR I = N TO 1 STEP -1
PRINT SET(I);
NEXT I
ENDIF
END
45. SOLUTION TO ACTIVITY 6-2(PG. 42) IN THE PRACTICAL MANUAL
CLS
REM PROGRAM TO CHECK ENTERED LETTER IF IT IS CAPITAL(UPPERCASE) OR SMALL(LOWERCASE)
INPUT “PRESS IN ANY ALPHABETICAL CHARACTER FROM THE KEYBOARD”; C$
IF (C$ >= “A” AND C$ <= “Z”) THEN
PRINT C$; “IS A CAPITAL(UPPERCASE) ALPHABET/LETTER”
ELSE IF (C$ >= “a” AND C$ <= “z”) THEN
PRINT C$; “IS A SMALL(LOWERCASE) ALPHABET/LETTER”
ELSE
PRINT C$; “IS NOT A LETTER/ALPHABET”
ENDIF
END
46. SOLUTION TO ACTIVITY 6-3(PG. 42) IN THE PRACTICAL MANUAL
CLS
REM PROGRAM TO REVERSE A GIVEN STRING
INPUT “READ IN ANY STRING”; TEXT$
FOR I = LEN(TEXT$) TO 1 STEP -1
REVTEXT$ = REVTEXT$ + MID$(TEXT$, I, 1)
NEXT I
PRINT “THE REVERSE OF STRING:”;TEXT$; “IS:”; REVTEXT$
END
47. SOLUTION TO ACTIVITY 6-4(PG. 42) IN THE PRACTICAL MANUAL
CLS
REM PROGRAM TO GENERATE A TRIANGLE OF A STRING OF 5 NUMBERS (e.g. 12345)
65
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
66
COURTESY: EDUCATION COMMITTEE, MSSN FUTA, OBAKEKERE MOSQUE (08161885095, 08069018655)
DOWNLOADED FROM FUTABASE.COM
* KEYNOTES
READ YOUR BOOK VERY WELL
BE FOCUS AND AIM HIGH
SUPPLICATE TO ALLAH(SWT)
BE CLOSE TO YOUR CREATOR AND MOVE AWAY FROM SINS
FEAR ALLAH MOST
67