Created
February 12, 2023 18:06
-
-
Save ImtiazEpu/7d7def0d9601686c23aba25056ba5642 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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