- #1
Matt512
- 17
- 0
Homework Statement
1.Rewrite this algorithm using a repeat until loop and then with a while loop.[/B]
Start
sum=0
Display "Input value n"
Input n
FOR( i=1 , i <=n , i+1 )
Input a value
sum=sum+value
ENDFOR
Output sum
Stop
I have some doubts if i have done the pseudo codes correctly.
2.Design an algorithm for finding the sum of the numbers 2,4,6,8,...,n
Can someone give me a leading clue on how to do it.
3.Write an algorithm to read 100 numbers then display the largest.
I am stuck midway.
Homework Equations
FOR( starting state , stopping condition, increment)
The Attempt at a Solution
Repeat until loop [/B]
Start
Repeat
sum=0
i=1
Display "Input value n"
Input n
Display "Input a value"
Input a value
sum=sum+value
i=i+1
UNTIL n>=i
Output sum
Stop
while loop.
Start
WHILE(n <>i)
sum=0
i=1
Display "Input value n"
Input n
Display "Input a value"
Input a value
sum=sum+value
i=i+1
ENDWHILE
Output sum
Stop
3.
START
count=0
sum=0
Input number
For( c=1 , c>100 , c+1)
sum=sum+value
ENDFOR
Output sum
Stop