Here is the program

use strict;
use warnings;

my ($div,$reminder) = &divide_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) = &divide_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, aichuab...@gmail.com (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: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to