# Perl Tutorials -Part 43- Nested loops

#perl example of nested loop @names = ('Amina', 'Bhimsen', 'Charles', 'Damien'); for ($i = 0; $i <6; $i++) { for ($k = 1; $k < 6; $k++) { print "$i multiplied by $k makes ". $i * $k . " \n"; } } Output:

0 multiplied by 1 makes 0 0 multiplied by 2 makes 0 0 multiplied by 3 makes 0 0 multiplied by 4 makes 0 0 multiplied by 5 makes 0 1 multiplied by 1 makes 1 1 multiplied by 2 makes 2 1 multiplied by 3 makes 3 1 multiplied by 4 makes 4 1 multiplied by 5 makes 5 2 multiplied by 1 makes 2 2 multiplied by 2 makes 4 2 multiplied by 3 makes 6 2 multiplied by 4 makes 8 2 multiplied by 5 makes 10 3 multiplied by 1 makes 3 3 multiplied by 2 makes 6 3 multiplied by 3 makes 9 3 multiplied by 4 makes 12 3 multiplied by 5 makes 15 4 multiplied by 1 makes 4 4 multiplied by 2 makes 8 4 multiplied by 3 makes 12 4 multiplied by 4 makes 16 4 multiplied by 5 makes 20 5 multiplied by 1 makes 5 5 multiplied by 2 makes 10 5 multiplied by 3 makes 15 5 multiplied by 4 makes 20 5 multiplied by 5 makes 25 |

Advertisements

## Leave a Reply