Write an algorithm and a flowchart to find sum of n numbers.
Answers
Answered by
15
Answer:
hope this helps
Explanation:
/* Sum of n natural numbers */
1.Start
2.Read the value of n.
3. i = 1 , S = 0
4. if ( i > n ) go to 8
5. S = S + i
6. i = i + 1
7. go to 3
8. Display the value of S
9. Stop
or
1. start
2. declare a sum variable and n.
3.Take a value of n.
4.Run while loop until n is greater than zero.
5.Add the current value of n to sum variable. Also, decrement n by 1 in while loop body.
6.display the value of sum variable, I.e sum
7.stop
Similar questions