Here is the program
use strict;
use warnings;
my ($div,$reminder) = ÷_now(20,4);
print "Dividend: $div\nReminder: $reminder\n";
sub divide_now {
my ($a,$b) = @_;
my ($s,$n);
for($n=1;;$n++) {
$d+=$b;
$s = $a - ($n*$b);
return($n,$s) if ($s<$b);
}
}
*** If you still want to use without '*' ********
use strict;
use warnings;
my ($div,$reminder) = ÷_now(20,4);
print "Dividend: $div\nReminder: $reminder\n";
sub divide_now {
my ($a,$b) = @_;
my ($s,$n,$d);
for($n=1;;$n++) {
$d+=$b;
$s = $a-$d;
return($n,$s) if ($s<$b);
}
}
On Apr 20, 4:20 am, [email protected] (ai nguyen) wrote:
> Hi there,
>
> How to write a device funciton without using a '/' operator
>
> sub device_now($a, $b){
> my ($a, $b)=@;
>
> <don't use $result=$a/$b; >
>
> return $result;
>
> }
>
> &device_now(6,3);
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/