Create a script using a for loop to add all the integers between 0 and 30 and display the sum
<?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
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer