...

View Full Version : Squares PHP program



catgillespie
11-19-2011, 07:20 PM
I need help with creating a PHP program with a table that will calculate the following: If anyone can help me get going with this I would greatly appreciate it!:confused

SQUARES
________________________________________

The square of 1 is 1
The square of 2 is 4
The square of 3 is 9
The square of 4 is 16
The square of 5 is 25
The square of 6 is 36
The square of 7 is 49
The square of 8 is 64
The square of 9 is 81
The square of 10 is 100

Thanks in advance!

votter
11-19-2011, 07:27 PM
You have already asked this question, and it was answered here:

http://www.codingforums.com/showthread.php?t=244142

catgillespie
11-19-2011, 07:47 PM
Yes, but it did not work for me!:

votter
11-19-2011, 07:49 PM
Then post in that forum what you are doing, what is not working, and what you are trying to do. There is no need making a new topic when you can get the answer in your other post. ;)

Adee
11-19-2011, 08:07 PM
This will work, sorry about the last thread lol



<?php

function sq($n) { return $n * $n; }

for($i = 1; $i<50; $i++)
{
echo "The square of $i is ". $i*$i ."<br />";

}

?>

catgillespie
11-19-2011, 08:30 PM
Yes! Thanks so much!:D



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum