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

MANUAL

Manual

Uploaded by

amubieyaayomide7
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)
21 views

MANUAL

Manual

Uploaded by

amubieyaayomide7
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/ 11

COS 102 - PRACTICAL

TABLE OF CONTENTS

MODULE 1 - ALGORITHM
1.1 Pseudo code
1.2 Students' assessment
MODULE 2 - FLOWCHART
2.1 Flowchart Symbols
2.2 Students' assessment
MODULE 3 - PROGRAMMING LANGUAGE
3.1 Low Level Language
3.2 Binary Operations
3.3 Students' assessment
MODULE 1
ALGORITHM
An algorithm is defined as sequence of steps to solve a problem (task). The steps must be
finite, well defined and unambiguous. Algorithm can also be defined as a plan to solve a
problem and represents its logic. In other words, an algorithm is a procedure for solving
problems. In order to solve a mathematical or computer problem, this is the first step in the
process. Note that an algorithm is of no use if it does not help us arrive at the desired solution.
Writing a logical step-by-step method to solve the problem requires some thinking.
An algorithm includes calculations, reasoning, and data processing. They can be presented by
natural languages, pseudocode, and flowcharts, etc. With algorithms, we can easily understand
a program.
Characteristics of Algorithm
 It should have finite number of steps. No one can be expected to execute infinite number of
steps.
 The steps must be in order and simple
 Each step should be defined clearly i.e. without un-ambiguity (without doubtfulness)
 Must include all required information
 Should exhibit at least one output

There are two forms of Algorithm namely, Pseudo code and Flow chart

PSEUDO CODE
Pseudo code (which means fake code, because it's not really programming code specifies the
steps required to accomplish the task. Pseudo code is a type of structured English that is used
to specify an algorithm. Pseudo code cannot be compiled nor executed, and there are no real
formatting or syntax rules.

Examples of Pseudo code


1. Pseudo code to find the average of three numbers
Step 1: Start
Step 2: Ask the user to input the first number
Step 3: Store the input in a variable named "num1"
Step 4: Ask the user to input the second number
Step 5: Store the input in a variable named "num2"
Step 6: Ask the user to input the third number
Step 7: Store the input in a variable named "num3"
Step 8: Add the three numbers together and store the result in a variable named "sum"
Step 9: Divide the sum by 3 and store the result in a variable named "average"
Step 10: Display the average to the user
Step 11: Stop

2. Pseudo code to find Area of a circle


Step 1: Start
Step 2: Ask the user to input the radius of the circle Step 3: Store the input in a variable
named "radius"
Step 4: Compute the area of the circle using the formula: area = pi * radius^2
Step 5: Display the area to the user
Step 6: Stop
STUDENTS' ASSESSMENT
1. Write pseudo code to find the average of five numbers.

2. Write pseudo code to determine if a given number is positive or negative.


3. Write pseudo code to determine if a person is eligible to vote based on their age.

4. Write pseudo code to determine if a person is eligible to apply for a ariver's license
based on their age.

5. Write pseudo code to determine if a number is negative or positive


MODULE 2
FLOWCHART
A flowchart is a graphical representation of an algorithm. These flowcharts play a vital role in
the programming of a problem and are quite helpful in understanding the logic of complicated
and lengthy problems. Once the flowchart is drawn, it becomes easy to write the program in
any high level language.
A flowchart is a diagram made up of boxes, diamonds and other shapes, connected by arrows -
each shape represents a step in the process, and the arrows show the order in which they
occur. Flowcharting combines symbolsand flow lines, to show figuratively the operation of an
algorithm.
Flowcharting Symbols
There are 5 basic symbols commonly used in flowcharting: Terminal, Process, input/output,
Decision, and Connector. This is not a complete list of all the possible flowcharting symbols; it is
the list of ones used most often instructured programming.
Symbol
Shape Purpose Description

Oval Terminal start/stop/begin/end.

Parallelogram Input/output Making data available for


processing (input) or
recording of the process
information (output).

Rectangle Process Any processing to be done. A


process changes or moves
data. An assignment
operation

Diamond Decision Decision or switching


type of operation

Circle Connector Used to connect different


parts of flowchart.

Arrow Flow Joins two symbols


and also represents flow of
execution.
RULES OF DRAWING FLOWCHARTS FOR ALGORITHMS
Knowing flowchart symbols well and using them involves critical thinking. Here are some basic
rules that need to be considered while drawing a flowchart.
1. All the boxes and shapes in a flowchart should be connected with arrows to indicate a
logical order and make it easy to follow.
2. Make sure the flow direction is consistent and not ambiguous. The flow charts always
flow from either left to right or top to bottom.
3. Every chart will begin with a Start box and end with a Terminal box, with the latter only
having one flow line associated with it.
4. All the shapes, symbols, and lines should be consistent. You can also add a symbol key
to make it easier to follow the chart.

Examples of Flowcharts
1. Calculate the Average of Two Numbers using flowchart
As you may have already known, to calculate the average of two numbers, you can sum
up those two numbers and divide the result by 2. In other words, the formula for
calculating the average of two numbers is: (number 1 + number 2)/2.
So the basic shapes of the chart should be like this:

START

Take Num 1, Num 2

Average = (Num 1 + Num 2)/2

Print Average

END
Example 2: Print 1 to 20:
Algorithm:
 Step 1: Initialize X as 0,
 Step 2: Increment X by 1,
 Step 3: Print X,
 Step 4: If X is less than 20 then go back to step 2.
Flowchart:
Flowchart Algorithm
3. Find the largest among three different numbers entered by the user.

Start

Declare variables a, b and c

Read a, b and c

False True
Is a > b?

True False False True


Is b > c? Is a > c?

Print b Print c Print a

Start

STUDENTS' ASSESSMENT
1. Create a flowchart to determine if a given number is even or odd.

2. Create a flowchart to determine if a given number is positive or negative.


3. Create a flowchart to determine the area of a rectangle.

4. Create a flowchart to determine the department a student belongs to based on their


matric number.
MODULE 3
PROGRAMMING LANGUAGE
The artificial languages that are used to develop computer program are called programming
language
There are two types of programming languages
1. Low Level Language
2. High Level Language

Low Level Language Low level programming languages are the codes that are easy to
understand by the computer and difficult for the user. These languages are also called machine
dependent because the program varies from machine to machine. These languages are used to
create the system program for the computer.

Types of Low-Level Language are as follows


1. Machine Level language
2. Assembly Language

Machine Level Language: This language is directly understood by the computer and does not
require any translator. In this language the codes are written in binary numbers i.e. O or 1. This
language is also known as binary languages. This language is very difficult for the programmers
and code may be different from machine to machine.

This language is very hard for the users to understand because all the codes are written in
binary numbers.
Assembly Language: In assembly language the codes are in the form of instructions and these
codes are called mnemonics. These codes are easier than the binary codes and perform the
specific task. It is easy for the programmer to write the codes. This language uses a translator
called assembler which converts the assembly level language into machine code. For examples
the code for addition is ADD, subtraction is SUB etc
Rules of Binary addition
a. 0+0=0
b. 0+1=1
c. 1 + 0=1
d. 1 + 1 = 10

Rules of Binary Subtraction

a. 0-0=0
b. 0 - 1 = 1 (Borrow 1)
c. 1-0=1
d. 1-1 = 0

Example of Binary Operation (Addition)


101
+101
1010

Example of Binary Operation (Subtraction)

STUDENTS' ASSESSMENT
1. What is the result of adding 1011 and 1101 in binary?
2. What is the result of subtracting 1101 from 10010 in binary?
3. What is the difference between 101010 and 1001 in binary?
4. What is the result of adding 111111 and 101010 in binary?
5. What is the result of subtracting 10011 from 101001 in binary?
6. What is the result of subtracting 100101 from 1011101 in binary?

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