Q1. Find the sum of the numbers in each set.
You are given hundred numbers divided in ten sets in the following order.
Set 1: 1-10
Set 2: 11-20
Set 3: 21-30
…
Set 10: 91-100
You have to draw a flowchart that will print the sum of each set.
Solution
To solve this problem we have to apply the concept of loop which was covered in exercise-1.
Algorithm in simple English
- Initialize count = 1 and i = 1 (PROCESS)
- Check if i is less than or equal to 10 (DECISION)
if YES then perform step 3
else STOP - Set sum = 0 and j = 1 (PROCESS)
- Check if j is less than or equal to 10 (DECISION)
if YES then perform step 5
else perform step 9 - Add count to sum
sum = sum + count (PROCESS) - Increment count by 1
count = count + 1 (PROCESS) - Increment j by 1
j = j + 1 (PROCESS) - Go to Step 4
- Print sum (I/O)
- Increment i by 1
i = i + 1 (PROCESS) - Go to Step 2
Flowchart