CSC 106

Assignment 1

To complete this assignment, you should hand in 4 files:

q1.pdf

q2.pdf

q3.pdf

q4.png

Note that the first three questions should be handed in as a PDF file. Do not hand in

any other files such as Microsoft Word files (e.g. doc). Question 4 needs to be handed

in as a proper screenshot in .png format (i.e. not a picture taken with a smartphone).

Q1) Pseudocode and Flow Charts (2 marks)

Below is Figure 1.2 from the textbook, which describes an algorithm for adding two

positive numbers together. Convert this pseudocode into a flow chart.

The following three consecutive questions build on one another

Q2) Question 2: pseudocode [2 marks]

Envision an algorithm that when given any number n, prints out the sum of 1 to n.

E.g. given 6 the algorithm would print 21 (because 1 + 2 + 3 + 4 + 5 + 6 = 21)

Write pseudocode for this algorithm using iteration (looping).

Now modify the algorithm (and pseudocode) so it prints out the sum of even, and

uneven numbers as well as the total sum.

For example if n was 6 it would print:

Even numbers sum: 12

Uneven numbers sum: 9

Total sum: 21

Again, to get marks, the algorithm needs to work for any n given.

Q3) Question 3: Flowchart [2 marks]

Create a flow chart from your pseudocode answer to Question 2

Q4) Question 4: Python implementation [4 marks].

Now implement your solution to Question 3 in Python using the application

provided at http://www.codeskulptor.org/

Once your application is running properly, please take a screenshot (not a picture

with your phone) and save it as q4.png

In order to get marks the picture needs to show your code, the output and the

unique url associated with your solution.

## Reviews

There are no reviews yet.