<?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 calculates the sum of digits in a given number. |
Write a PHP script that generates and displays a simple multiplication table for the numbers 1 to 5. |
how to get current latitude and longitude using google map api in php? |
How to show location using google map in JavaScript? |
How to check whether a given year is a leap year using php. |
Create a PHP script that checks whether a given number is a prime number or not. |
Write a PHP script that connects to a MySQL database and fetches data from a table. |
Write a PHP script that calculates the factorial of a given number using an iterative approach. |