### Table of Contents

# Programming primer

## PROCESSING

Topic: **How data change in a computer?**

9 and 10 period

**Question: ** What does this program do? (Answer: Add two numbers and write the result.)

*Tip: Pupils already know first and second instruction. (Repeat INPUT and let them execute first and second instruction with use of Mema.) They should remember what the fourth instruction does.*

**Question: What does the third instruction do?**

**Answer: ** The third instruction expect that we fill the green drawer with as many grains as is the sum of red and blue drawer is. This instruction is neither INPUT nor OUTPUT, but the data are changed and is cold PROCESSING. So execute this instruction with use of MEMA.

At the end repeat OUTPUT using the forth instruction and MEMA.

**Assignment:** What will be the OUTPUT from the program above, if in the blue drawer we put 5, and in the red 3? (Solution: 8)

*Question: Explain Whay?**Explanation: If the INPUT in the blue drawer was 5 grains and in the red one 3 grains, then the contents after third instruction in the green drawer must be 8, becouse 5 3=8.**The OUTPUT ist from the green drawer, so it must be 8.**Question: Does the fotth instruction request to empty the green drawer? (Answer: No, we have only to write how many grains are there in the green drawer without changing the contents of it.)*

**Assignment**: Fill in the table using Mema and the program for adition of two numbers.

If in the blue drawer enter this number of grains, | 5 | 2 | 7 | 9 | 3 | 4 | 14 |
---|---|---|---|---|---|---|---|

And in the red this one | 4 | 3 | 12 | 8 | 16 | 15 | 5 |

What will be the OUTPUT from the green drawer? |

**Question: ** What does this program do? (Answer: Multiply two numbers and write the result.)

**Tip:** Step by step description of this program is that this program requires INPUT in blue and red drawer, and then multiply this two numbers and put the result in the yellow drawer, followed by OUTPUT from yellow, so that we can see what was the result.

**Question:** If the program for multiplaying use as INPUT 2 and 6, what will be the OUTPUT (Answer:12.)

**Question:** What should be the INPUT in blue and red drawer, if we want have 6 as OUTPUT?

**Answer: ** There are many correct answers: 2 and 3 or 3 and 2 or 6 and 1 or 1 and 6.

**Assignment**: Fill in the table using Mema and the program for multipliing two numbers.

If in the blue drawer enter this number of grains, | 5 | 2 | 7 | 9 | 3 | 4 | 10 |
---|---|---|---|---|---|---|---|

And in the red this one | 4 | 3 | 7 | 8 | 6 | 4 | 5 |

What will be the OUTPUT from the yellow drawer? |

**Question: ** What does this program do? (Answer: Divide the second number by the first and write out the result.)

Comment for the teacher: Let the students say what the program does. The answer may be short or more extensive mentioning drawers and grains, Important is that students become aware of what the program does and what happens with data.

**Assignment**: Fill in the table using Mema and the program for division of two numbers.

If in the red drawer enter this number of grains | 8 | 6 | 14 | 9 | 10 | 24 | 49 |
---|---|---|---|---|---|---|---|

And in the blue this one | 4 | 3 | 7 | 3 | 5 | 8 | 7 |

What will be the OUTPUT from the yellow drawer? |

## PLAY

Clicking the link Play - Scenario "My computer" you can go to the next lesson.