Exercise 3
Problem: Sum the first 100 odd number
The first 100 odd numbers are covered in range 0 to 200 with first odd number is 1 and the last is 199, thus total summation is 1+3+5+7+9...+199
Initially one variable sum in initialized to 0. Then subsequently 1,3,...199 added to it. To keep track of number of addition, a counter is maintained with initial value is 0. Every time addition is made, counter is incremented. When it is 100, all number are added and process is completed.
Algorithm:
1. SUM = 0
2. COUNT = 0
3. ODD = 1
4. SUM = SUM + ODD
5. ODD = ODD + 2
6. COUNT = Count + 1
7. If COUNT < 100, goto 4
8. Print SUM
9. STOP
Flowchart: