Q:

Create a script using a for loop to add all the integers between 0 and 30 and display the sum

0

Create a script using a for loop to add all the integers between 0 and 30 and display the sum

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

<?php
$sum = 0;
for($x=1; $x<=30; $x++)
{
$sum +=$x;
}
echo "The sum of the numbers 0 to 30 is $sum"."\n";
?>

Sample Output:

The sum of the numbers 0 to 30 is 465

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now