Print square and also print sum of the number in PHP
<?php
/* Write a program to print square and also print sum of the number.*/
$a=1;
$b=0;
$sum=0;
while($a<=10)
{
$b=$a*$a;
print"<br>".$b;
$sum=$sum+$b;
$a++;
}
print"<br>Sum = ".$sum;
?>
No comments:
Post a Comment