Introduction To Algorithms and Scratch
Introduction To Algorithms and Scratch
• Step 1 : Start
• Step 2 : Input numbers 1 , 2
• Step 3 : Add two numbers and store as SUM
• Step 4 : Print the value of SUM
• Step 5 : Stop
Example 2) Making a phone call to your friend:
Step 1 : Start
Step 2 : Pick up the receiver.
Step 3 : Listen to the dial tone.
Step 4 : Dial your friend's number.
Step 5 : Say Hello
Step 6 : Talk to your friend.
Step 7 : Say Bye Bye, after talking.
Step 8 : Put down the receiver.
Step 9 : Stop
Example 3) To save a document in Microsoft Word
• Step 1 : Start
• Step 2 : Click on File Menu.
• Step 3 : Click on Save.
• Step 4 : Choose the target folder.
• Step 5 : Type Filename.
• Step 6 : Click on Save.
• Step 7 : Stop
• A logical test is a test that has the answer as either True or False.
• They are used together with relational operators
• For example:
a) 4 > 3 ? The answer is True
b) 10 < 5 ? The answer is False
c) 50 = 10 ? The answer is False
2) Logical operators block:
• To make a logical test a relational operator is used.
• Relational operator are represented in ‘green dot’
• Let us now use the conditional if…then block with relational operator
block.
Creating a Program using conditional structures
1) If….then block
a) Found when you click on the orange dot
b) Has several blocks: Repeat, forever, repeat until…
c) Used together with relational operators
Run the program and see what happens
2) If…..else block
Solution
1.Create an algorithm
2.Create a program plan
3. Solve using scratch
Exercise 1
Problem: Calculate the addition of two numbers input by a user