Skip to content

Instantly share code, notes, and snippets.

@ImtiazEpu
Created February 12, 2023 18:06
Show Gist options
  • Save ImtiazEpu/7d7def0d9601686c23aba25056ba5642 to your computer and use it in GitHub Desktop.
Save ImtiazEpu/7d7def0d9601686c23aba25056ba5642 to your computer and use it in GitHub Desktop.
<?php
//Q: Write a Reusable PHP Function that can check Even & Odd Number And Return Decision
function check_even_odd_number($number): string {
if ($number % 2 == 0) {
return "The number is even.";
} else {
return "The number is odd.";
}
}
$result = check_even_odd_number(83);
echo $result;
//Q: 1+2+3...…….100 Write a loop to calculate the summation of the series
$sum = 1;
for ($i = 1; $i <= 100; $i++) {
$sum += $i;
}
echo "The summation of the series is {$sum}.";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment