+ 1
Array a[1,3,2,6,5,4,8,9,0] 1)Find the even numbers on the about array 2)Find the odd number position on the above array
another one interview question
1 Réponse
+ 1
$a = array(1,3,2,6,5,4,8,9,0);
for($i = 0; $i < count($a); $i++){
$rem = $a[$i]%2;
if($rem == 0){
$evens[ ] = $a[$i];
}else{
$oddpos[ ] = $i;
}
}
echo "Even numbers : ";
print_r($evens);
echo "<br>Odd Positions : ";
print_r($oddpos);