Re: coding help
On 1 March 2016 at 19:35, Arghya Das wrote: > $num = 1234; > $sum = 0; > > while ( $num != 0) > { > $rem = $num % 10; > $sum = ( $sum * 10 ) + $rem; > $num = $num / 10; > } > > print $sum; I suspect you're just exceeding precision limits. Modified code: use strict; use warnings; my $num = 1234
coding help
$num = 1234; $sum = 0; while ( $num != 0) { $rem = $num % 10; $sum = ( $sum * 10 ) + $rem; $num = $num / 10; } print $sum; please tell what is wrong with the reverse number code . It prints Infinity.