How to calculate Square of an integer without using pow()

Dear friends,
Take this as an assignment, figure out way to calculate square of a number without using the library functions in php.

1 Like

Here is the code…

<?php 

//number
$num = 5;
//calculate & printing square
echo "square of " .$num ." is = " .$num*$num;
  
?>
4 Likes

That’s correct!

Since the basic fundamental of square is a number multiplied by itself, this code will work fine.

1 Like