
Originally Posted by
chillerbros17
Consider the following algorithm.
Input X
A:= 0
B:= 0
Count:= 1
While X <>0
If > A then
Do
A:= X
B:= Count
End Do
Input X
Count :=Count + 1
End While
Output A, B
Suppose the inputted values of x are:
3, 4, 2, 9, 3, 9, 2, 0, 4, 7, 1 (all values may not be used)
(a) Trace through the algorithm.
(b) Given a list of numbers, what will A output and what will B output?
1). Indentation is very helpful in following pseudo code, you can use [code]..[/code]
tags to delimit a code block where the indentation will sort of work:
Code:
Input X
A:= 0
B:= 0
Count:= 1
While X <>0
If > A then
Do
A:= X
B:= Count
End Do
Input X
Count :=Count + 1
End While
Output A, B 2). What do you want the "> A" in "If > A then" to mean?
RonL