Odd or even with function | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
0

Odd or even with function

<?php Function OE($a){ $b=$a%2; return$a ; if (b==0) echo "even" ; else echo " odd" ; } echo OE(88); ?>

27th Oct 2019, 12:48 PM
masih
masih - avatar
11 Respuestas
+ 2
here is the correct one. no need for return $a and no need for $b <?php Function OE($a){ $a=$a%2 ; if ($a==0){ echo "even" ; }else{ echo " odd" ; } } echo OE(88 ); ?>
27th Oct 2019, 1:34 PM
Bahhaⵣ
Bahhaⵣ - avatar
+ 1
is this a question or what?
27th Oct 2019, 1:13 PM
Bahhaⵣ
Bahhaⵣ - avatar
+ 1
Is this program ok? Determine the even or odd number
27th Oct 2019, 1:23 PM
masih
masih - avatar
+ 1
/ wrong % True
27th Oct 2019, 1:32 PM
masih
masih - avatar
+ 1
Replacing the / with %, doesnt yet fix the program, because you have return statement, which will break the function call before the if-else statement is reached.
27th Oct 2019, 1:35 PM
Seb TheS
Seb TheS - avatar
+ 1
I want with function for program
27th Oct 2019, 1:36 PM
masih
masih - avatar
+ 1
% is remind for number I think true
27th Oct 2019, 1:39 PM
masih
masih - avatar
+ 1
My from iran
29th Oct 2019, 10:47 AM
masih
masih - avatar
0
I think it's wrong. n/2 == 0 does not mean that n is even.
27th Oct 2019, 1:29 PM
Seb TheS
Seb TheS - avatar
0
az iran
29th Oct 2019, 9:02 AM
pouya
0
az iran
29th Oct 2019, 9:02 AM
pouya