<?php
$sum = 0;
for ($i = 2; $i <= 10; $i += 2) {
$sum += $i;
}
echo "The sum of even numbers between 1 and 10 is: $sum";
?>
<?php
$sum = 0;
for ($i = 2; $i <= 10; $i += 2) {
$sum += $i;
}
echo "The sum of even numbers between 1 and 10 is: $sum";
?>
Related
Write a PHP script that checks if a given string is a valid email address. |
How to convert a temperature from Celsius to Fahrenheit using php. |
Write a PHP script that connects to a MySQL database and fetches data from a table. |
Write a PHP script that calculates the sum of digits in a given number. |
Write a PHP script that calculates the factorial of a given number using an iterative approach. |
Create a PHP script that prints the current date and time. |
Create a PHP script that calculates the average of an array of numbers. |
How to get the largest element in an array of numbers |