Friday, 18 February 2011

Dry Algorithm Question

Complete Table for Following lIne of Code:

1  X = 1
2  REPEAT
3           A = X*X
4           OUTPUT X,A
5           X = X + 1
6  UNTIL X = 3
7  END

Table:

Line       X        A        Output              Condition
1            1        
3            1          1
4            1          1           1,1
5            2          1
6            2          1                                     False
3            2          4
4            2          4           2,4
5            3          4
6            3          4                                     True
7 - End

1 comment: