2. Solving Problem Activities
1. Define The problem.
2. Analyze the problem
Analyze
Define
Develop An Algorithm
Write A program
Test & Debug
3. Develop an algorithm for solving the problem
4. Write program corresponding to the algorithm.
5. Test and Debug the program
By: Ragia Ibrahim 2
االحصائيه والبحوث الدراسات معهد القاهرة جامعة
والبرمجيات المعلومات قواعد بحوث مركز
3. What is an Algorithm?
A Set of instructions that if followed, will produce a
solution for a given problem. Algorithm instructions should
be written in a form that would be easily converted into
computer instructions.
By: Ragia Ibrahim 3
االحصائيه والبحوث الدراسات معهد القاهرة جامعة
والبرمجيات المعلومات قواعد بحوث مركز
5. Flowchart Symbols, Example.
Start OR End
Input Data
Condition
Print output
Process
By: Ragia Ibrahim 5
االحصائيه والبحوث الدراسات معهد القاهرة جامعة
والبرمجيات المعلومات قواعد بحوث مركز
6. Example1
Convert from Square meter to square yard: 1 Square yard=1.196 Square meter
Stop
Start
“Enter Square
Meters”
Store
Value
In M
Y=M*1.196
Print Y
By: Ragia Ibrahim 6
االحصائيه والبحوث الدراسات معهد القاهرة جامعة
والبرمجيات المعلومات قواعد بحوث مركز
7. Example2
Find the Largest
number Among three
Numbers
Stop
Start
“Enter three Numbers”
Store Value In
X, Y, Z
Print L
By: Ragia Ibrahim 7
IF X>Y L=X
IF Z>L
L=Y
L=Z
االحصائيه والبحوث الدراسات معهد القاهرة جامعة
والبرمجيات المعلومات قواعد بحوث مركز
8. Example3
Find the reminder
and quotient upon
dividing non
negative integer by
a positive integer.
Stop
Start
“Enter dividend and divider”
Store Value In
X, Y
Print Value of R, Q
By: Ragia Ibrahim 8
IF
R>=Y
R=X
Q=0
R=R-Y
Q=Q+1
االحصائيه والبحوث الدراسات معهد القاهرة جامعة
والبرمجيات المعلومات قواعد بحوث مركز
10. 10
Q1
Start
“Enter pair of integers”
Store Value In
X, Y
IF
y mod
y=x
false
true
Endاالحصائيه والبحوث الدراسات معهد القاهرة جامعة
والبرمجيات المعلومات قواعد بحوث مركز
11. االحصائيه والبحوث الدراسات معهد القاهرة جامعة
والبرمجيات المعلومات قواعد بحوث مركز
11
Q2
A perfect number is a positive integer that is
equal to the sum of its proper positive
divisors, that is, the sum of its positive
divisors excluding the number itself
Example:
Factors of 6 are 1,2,3
1+2+3 = 6
Factors of 28 are 1,2,4,7,14
1+2+4+7+14=28
Stop
Start
“Enter Positive Integer Number”
Store Value In
N
Print “Not perfect”
f<= N/2
Sum=0
f=1
F=f+1
Sum=Sum+f
N mod f=0
s=n
Print “perfect”
12. االحصائيه والبحوث الدراسات معهد القاهرة جامعة
والبرمجيات المعلومات قواعد بحوث مركز
12
Q3 Start
“Enter Positive Integer Number”
Store Value In
N
i<n
i=2
prime= true
i++
prime= false
n mod i = 0
print prime
Stop