Perl code of Calculate square root

print "Enter the number:=";
$aa=<>;
chop($aa);
@aaa=split('',$aa);
if($aaa[0]=~ /^-/)
{
shift(@aaa);
}
$a=join('',@aaa);
#print "$a";
$a1=$a/2;
for($i=0;$i<10;++$i)
{
$a2=$a/$a1;
$a1=($a1+$a2)/2;
}
print "$a1";

RESULT:-














thanks...have a nice day
by Anop Singh Ranawat

Comments

Popular posts from this blog