Question 1037893: Write the algorithm, flow chart and the basic programs to complete the sum of the first ten integers.
Found 2 solutions by Alan3354, Edwin McCravy: Answer by Alan3354(69443) (Show Source):
You can put this solution on YOUR website! Write the algorithm, flow chart and the basic programs to complete the sum of the first ten integer's [sic]
===============
There are 10 of them.
Add 5 pairs:
1 + 10 = 11
2 + 9 = 11
etc.
--> 5*11 = 55
=====================
PS It's integers, not integer's
Answer by Edwin McCravy(20055) (Show Source):
You can put this solution on YOUR website!
Algorithm:
1. Start with N=0,
2. Start with SUM=0,
3. Add 1 to N
4. Add N to SUM
5. If N=10 then print SUM, if not, go to 3
6. End
The following should give you an idea of how
your flow chart should look:
N=0
↓
SUM=0
↓
Add 1 to N ← ←
↓ ↑
Add N to SUM ↑
↓ ↑
N=10? → NO → <--This is a decision, so
↓ enclose in diamond shape,
YES others in rectangles
↓
Print SUM
↓
End
Here's the program in LibertyBasic. You may have to
translate it into whatever language you are using:
N=0
SUM=0
1 N=N+1
SUM=SUM+N
if N=10 then print SUM else 1
end
Edwin
|
|
|