Trusted by millions of Kenyans
Study resources on Kenyaplex

Get ready-made curriculum aligned revision materials

Exam papers, notes, holiday assignments and topical questions – all aligned to the Kenyan curriculum.

Write an algorithm that can be used in calculating and outputting the sum of the first 35 natural numbers.

Write an algorithm that can be used in calculating and outputting the sum of the first 35 natural numbers.

Answers


Kavungya
Step 1: Initialize the variables that include:
i) Counting Variable – this variable is for tracking the number of values entered. Let it be initialized as: Count = 0
ii) Sum Variable – this is the variable on which the sum values are stored. Let it be initialized as: Sum = 0
Step 2: Reading of values. Let a value be represented by letter “X”
Step 3: Computing the sum; this process is represented as:
Sum = Sum + X
Step 4: Updating the counting variable; this is represented as:
Count = Count + 1
Step 5: Decision Point i.e. establishing whether the Count value is equal to 35
i) If NO, then go back to step 2 to read the next number
ii) If YES, go to step 6
Step 6: Output the total Sum
Kavungya answered the question on May 15, 2019 at 15:01

Answer Attachments

Exams With Marking Schemes

Related Questions