Professional Documents
Culture Documents
Chapter 1
Chapter 1
Ex:-
(Tea + Water ) Boiling +sugar = Cup of tea
Ex:-
Take a bus pay money Bus running = Arrive school.
Ex:-
Digging (cement + sand ) + iron Workers = Building
oblem solving steps :-
1. Problem definition . Output 7
تحديد المشكلة Input 3,4
Solution 7 = 4+3
2. Step-by-step instructions . Algorithm
Flowchart
3. Program design .
4. Program Testing .
5. Program Documentation .
First: Problem Definition:
8 4,2 8=4*2
Second: Performing step-by-step instructi ons
(Algorithm) to solve a Problem
Draw
Flow chart
Third: Program design
We have to translate this flowchart into one of the
programming languages to create a program.
programming
Fourth: Program Testing
During writing a program we make some mistakes
Ex:-
Area of circle = 3.14 + R^2
We can’t detect errors unless we begin entering data to the program with previously
known results; to compare the results of the current program to those of the well-
known results.
Ex:-
Predefined result 3.14*5^2 = 78.5
If (R=5 cm)
Significance Symbol
Terminal ( Start , End )
) = ( Process
Calculate , Compute
Flow lines
- Simple
Types of flowchart - Branching
- Looping
1- Start Start
3 – Sum = A + B Sum= A+ B
2 -EnterEnter
x,y,z x,y,z
3- avg=(x+y+z)/3
Avg=(x+y+z)/3
pro=x *y*z
Pro=x*y*z
4- Print avg , pro
Print avg,pro
5-End
End
Exercise 1:-
Calculate the area of circle Area = 3.14 * R ^2
First: - Define the problem:-
Output: - Area of circle input
output
Input:- Radius (R)
Solution: - Area = 3.14 * R ^2
Third :- Flowchart Second :- Algorithm
Start
1- Start
Enter R
2 -Enter R
4- Print Area
Print Area
5-End
End
Exercise 2:-
Calculate the number of years using a known number of months
First: - Define the problem:-
Output: - Years (y) Y = m / 12
Input:- Months (m) input
Solution: - Y = m / 12 output
Start
1- Start
Enter m
2 -Enter m
3- y = m / 12 Y = m / 12
4- Print y
Print y
5-End
End
2- Branching flow chart:- ?
Ex 1:-
Draw a flowchart for a program that obtains exam scores from the user
and determines whether the score is greater than or equal 50 and
display the message "Successful".
Start
1- Start
Enter d
2- Enter ( d )
Yes Print
3- If d>=50 , then If d>=50
“Successful“
3.1- Print “Successful”
No
4- End
End
Ex 2:-
Draw a flowchart for a program that compares between two number
and to know which of them is greater than the other showing a
message “The largest number is…..”.
Start
1- Start
Enter x , y
2- Enter x , y
Print “the
Yes largest
3- If x>y , then If x > y
number is x
3.1- Print “the largest number is “
x” No
Draw a flow chart for a program that calculates the division of two
numbers .Determine whether the divisor equal “ Zero“ and display the
message “ Unknown “.
1- Start
Start
2- Enter x , y
3- If y =0 then, Enter x , y
1- 1 ا لبداية ؟ No Yes
N <=3
2- 3 ا لنهاية ؟
3-1 مع دلا لزيادة ؟ Print N
N= N +1
End
Flowchart Algorithm
1- Start
2- N=1
3- If N<=3 then,
3.1- Print N
3.2 – N= N + 1
3.3 – Go to step 3
4-End
How many times was the content of the loop executed? 3 times
What will be the value of M at the end of the loop? 4
Ex 2:-
Draw a flow chart to print the multiplication table of number 3 .
N N*3
1* 3 = 3
2* 3 = 6
3* 3 = 9
4* 3 = 12
.
.
.
12* 3 = 36
Flowchart Algorithm
1- Start Start
2- N=1
N= 1
3- If N<=12 then,
3.1- Print N * 3 No
N <=12 N= N +1
3.2 – N= N + 1
End
Questions