Wednesday, October 19, 2022

Multiplication table in perl 5

 

# $num is available as number passed to print the table

# initialize variable to use in while loop

$ans = "xyz"; #return the correct value in this string

#write your code for while loop here
$i=1;
$ans="";
while($i<=10)
{
    $temp=$num*$i;
    $ans.=$temp." ";
    $i+=1;
}

return $ans;

No comments:

Post a Comment