Sunday, 30 October 2016

Trace tables

Trace tables
trace table is a technique used to test algorithms, in order to make sure that no logical errors occur whilst the algorithm is being processed. ... They can be an essential tool in teaching students how a certain algorithm works and the systematic process that is occurring when the algorithm is executed.

for example:

Dim number As Integer
Dim num2 As Integer

Sub Main()

number = 4 

Do

     Num2 = number * 2
     Console.Writeline(Num2)
    number = number - 1

    Loop Until number = 0

    Console.Readline()
End sub

the trace table for his piece of coding would look like this:


Number                       Num2                     Output
4                                  8                             3
3                                  6                             2
2                                  4                             1
1                                  2                             0
0                                  -                              -




No comments:

Post a Comment