CSC102 - Sessionhared-1
CSC102 - Sessionhared-1
CSC102 - Sessionhared-1
CSC102
Biralatei. J. Fawei
Biriyai Okolai
Assessment
Ø Examination (70%)
§ Hand written examination
§ Examination 2 hours
§ To answer 4 questions
Example of common
input device
§ Keyboard
§ Mouse
Output Unit
The output unit displays information
that has been processed
a) Problem Definition
b) Problem Analysis
c) Algorithm design & representation
(pseudo-code and flowchart)
1. Start
2. Let a, b, c, d and e and avg be variables for the
five numbers & average respectively.
3. Assign values to the declared variables
4. Compute for avg
5. Let avg = (a+b+c+d+e)/5.0
6. Display avg as output
7. Stop and End Program
PROGRAM DEVELOPMENT LIFECYCLE
(Contd.)
3b. Pseudo-code representation:
This is a notation that resembles a
programming language to be used in solving the
given problem. It is used for interpreting the
algorithm
1. program average
2. var a,b,c,d,e,avg;
3. read a,b,c,d,e
4. avg = (a+b+c+d+e)/5
5. write (“average of 5 numbers,’avg’’);
6. end
7.
PROGRAM DEVELOPMENT LIFECYCLE
(Contd.)
3c. Flowchart:
This is the diagrammatic representation of an
Algorithm. It uses the following Symbols
PROGRAM DEVELOPMENT LIFECYCLE
(Contd.)
Flowchart:
PROGRAM DEVELOPMENT LIFECYCLE
(Contd.)
4. Coding and Debugging:
After constructing the algorithm, it is now
possible to code with any program language and
test-run.
INSTRUCTION:
32, 43, 7, 58, 97, 41, 30, 83, 56, 77, 40,
12, 90, 72, 69, 55, 37, 44, 61, 53, 88, 94,
76
Problem Solving
Please, pick up your pen and paper, and
find the average of the set of numbers
32, 43, 7, 58, 97, 41, 30, 83, 56, 77, 40,
12, 90, 72, 69, 55, 37, 44, 61, 53, 88, 94,
76
32, 43, 7, 58, 97, 41, 30, 83, 56, 77, 40,
12, 90, 72, 69, 55, 37, 44, 61, 53, 88, 94,
76
Problem Solving
Instructing computer to find the average
of a set of numbers:
Finding average
1. Addition of the numbers
2.
3. Count the set of numbers
4.
5. Divide Addition by Count
6.
Define a procedure
Draw up a precise plan for the computer to
execute
ie. Draw up an algorithm
Pseudo code
1. Set sum and count to 0
2. Load set of numbers
3. Repeat x number of times
1. Sum = add number
2. Count = add x
4. Average = divide sum by count
5. Display Average
Algorithm
From our example problem, find the average
of a set of numbers:
A Flowchart
Algorithm
From our example problem
Pseudo code
1. Set sum and count to 0
2. Load set of numbers
3. Repeat x number of times
1. Sum = add number
2. Count = add x
4. Average = divide sum by count
5. Display Average
A Flowchart
Algorithm
Pseudocodes and flowcharts may vary
depending on the author
• Condition: taking a
decision of what to do
next
• Repetition (Loop): do
same thing in a given
number of times
Control structures
• Storage: storing information
to be used later in the
program
•
Pseudo code
Sequential
1. Set sum and count to 0
2. Load set of numbers
3. Repeat x number of times
1. Sum = add number Repetition
2. Count = add x
4. Average = divide sum by count
5. Display Average
Algorithm
From our example problem
Sequential
Repetition
Write program