Arguments! - Answer to exercise 1

$t = $ARGV[0];

$n = $ARGV[1];

print "This is the $t times table.\n";

for ( $i = 1; $i <= $n; $i = $i + 1 )
{
    $t_times_i = $t * $i;

    print "$i times $t equals $t_times_i\n";
}

Compare with Python


Previous Up Next