Write an iterative algorithm to find sum of n numbers
Answers
Answered by
8
1. Start
2. Input n, sum = 0
3. Start a Loop, from i=1 to i=n Body of Loop { Input x, sum = sum + x }4. Output Sum5. End
2. Input n, sum = 0
3. Start a Loop, from i=1 to i=n Body of Loop { Input x, sum = sum + x }4. Output Sum5. End
Answered by
1
1. Input the value of n.
2. Initialize i = 1 , SUM = 0
3. Apply condition if ( i > n ) go to 7
4. S = S + i
5. i = i + 1
6. go to 3
7. Display the value of S
8. Stop
2. Initialize i = 1 , SUM = 0
3. Apply condition if ( i > n ) go to 7
4. S = S + i
5. i = i + 1
6. go to 3
7. Display the value of S
8. Stop
Similar questions