Presentation is loading. Please wait.

Presentation is loading. Please wait.

Exercise (1). Example: - Using Pseudo code, Write suitable algorithm: - Calculate and print the average temperature, readings for the degrees as the following.

Similar presentations


Presentation on theme: "Exercise (1). Example: - Using Pseudo code, Write suitable algorithm: - Calculate and print the average temperature, readings for the degrees as the following."— Presentation transcript:

1 Exercise (1)

2 Example: - Using Pseudo code, Write suitable algorithm: - Calculate and print the average temperature, readings for the degrees as the following T1, T2, T3. 2 Input T1, T2, T3 avg= (T1 + T2 + T3)/3 avg= (T1 + T2 + T3)/3 Print avg Input T1, T2, T3 Sum = (T1 + T2 + T3) Avg = sum/3 Print avg

3 Flow chart Flow chart Start or Stop Program Input or Output Process, Calculate, Storage Arrows determine the direction of the program's progress Used to express logical operations or operations report (Condition) Connection

4 Sum = T1+T2+T3 Flow chart - Example : - Using flow chart, Write suitable algorithm: - Calculate and print the average temperature for the following readings T1, T2, T3. start Input T1, T2, T3 Avg = sum/3 Print avg stop : Input : T1, T2, T3 Processing : Sum = T1+T2+T3 Avg = sum/3 Output: Avg = sum/3

5 Using pseudo code and flow chart to write an algorithm. Enter number (X) and then find and print the value (Y), as shown in the following equation: Y=(X-2)/X Y=(X-2)/X Note: (if X=0 enter value of X again) start stop Input X Y=(X-2)/X Print Y If X=0 yes No Flow Chart Pseudo code input X process if x=0 Re-enter the new value of x because you can not divide by 0 “ Y=(X-2)/X output Y

6 Sum= T1+T2+T3 Flow chart Example: - Using flow chart, Write suitable algorithm: - Calculate and print the average temperature. Readings as the following T1, T2, T3. - IF the average is greater than 15 print the average, else print the weather is cold. start input T1, T2, T3 Avg = sum/3 Print avg avg > 15 Print “cold” Stop Start Input T1,T2,T3 Sum = T1+T2+T3 Avg = sum/3 If avg > 15 then Print avg Else Print “cold” End if end NoYes

7 Discuss Write an algorithm using pseudo code and flow chart for the introduction of 3 degrees and find the average temperature and print the "cool air“ if temperature less than 15, Print "moderate air” if temperature between 15 and 25, and print “hot air” if the temperature not verify the previous conditions. 7

8 Answer : If avg<15 End Yes No If avg<25 Print cool Yes No Print moderate Print hot

9  Using pseudo code and flow chart to write an algorithm to calculate the area and perimeter of ​​ a rectangle. Note: the area of ​​ the rectangle = length × width. Perimeter = 2*(length+width) Perimeter = 2*(length+width) 9

10  Using pseudo code and flow chart to write an algorithm to calculate and print the area of a right-angled triangle. The base of the triangle = a The height of triangle= b Equation of area= (1/2)*a*b Equation of area= (1/2)*a*b

11 Write a program using the pseudo code and flow chart to find the area of ​​ a circle which radius R print it. Note: The area of ​​ a circle is equal to π * R 2, where π is a constant value of approximately 3.14. Input R Process Π = 3.14 A= π × R × R output Print A End Pseudo code flow chart start Input r π × r × A= r Print A End π = 3.14

12 Using the methods (pseudo code and flow chart), we need to find and print the vicinity of the football stadium, and determine whether international (greater than or equal to 600 m) or local (less so), Using the methods (pseudo code and flow chart), we need to find and print the vicinity of the football stadium, and determine whether international (greater than or equal to 600 m) or local (less so), Note: The perimeter of the rectangle is equal to (length + width) × 2. Note: The perimeter of the rectangle is equal to (length + width) × 2. Start Input L, W C= 2× ( L + W) If c ≥ 600 then Print “ international” Else Print “ local” End if print c End flow chart C= 2* (L+W) start Input L,W Print Internationa l End If C>=600 Print Local YesNo

13 Formulate resolve the matter to find the zakaah and that if you know money saver and you know that zakaah = 0.025 × money saver, provided the account of zakaah money if it exceeds 1000 SR start stop Input M K=M*0.025 Print k M>1000 no yes Flow chart Pseudo code Input money m Process If m>1000 calculate zakaah else do not calculate zakaah zakaah=0.025*money Output print zakaah

14 Output: print output from 1 to 49 Input: no input Process: transfer from odd number to odd number no=1 Print no no=no+2 If no>50 then stop else go to step (2) start stop No=1 Print No No=No+2 No>50 no yes Pseudo code Formulate a solution to print the odd numbers from 1 to 49 ? Flow chart

15  Write a program that accept an integer from the user and print it is Positive or Negative number.

16  Write a program that accept an integer from the user and test the number. If it is positive print Positive, if it is negative print Negative if equal zero print equal zero.

17 start Enter number (n) n>0 N<0 Print “positive” Print “negative” print “equal zero” end yes No  Use flow chart to write algorithm. Read an integer from the user and test then number. If it is positive print Positive, if it is negative print Negative if equal zero print equal zero.


Download ppt "Exercise (1). Example: - Using Pseudo code, Write suitable algorithm: - Calculate and print the average temperature, readings for the degrees as the following."

Similar presentations


Ads by Google