Exercise 1.1

One student will explain how to draw an image under the following restrictions.

The rest of the students should try to draw the figure according to the instructions.

Exercise 1.2

Explain what the following algorithm does.

  1. Given: two positive natural numbers a & b
  2. Set remainder = some non-zero value
  3. Repeat these steps until remainder = 0
    1. Set remainder = the remainder of a divided by b
    2. If remainder = 0 Then
      1. Print GCD is b
    3. Else
      1. Set a = b and b = remainder
    4. Go on to the next repetition
  4. Test Cases: GCD(36,16)→4; GCD(1,1)→1; GCD(1260,198)→18

Exercise 1.3

Write an algorithm for sorting cards under the following restrictions.

Exercise 1.4

Write algorithms that implement solutions to the following problems.

  1. We’d like to print the following famous phrase “My name is Bond, James Bond.” using whatever first and last names the user enters.

  2. We’d like to print the sum of any two numbers the user enters.