+ 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

5th Oct 2016, 8:11 AM
Vengateshwaran Sivakumar
Vengateshwaran Sivakumar - avatar
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);
5th Oct 2016, 7:23 PM
Rajesh Patra
Rajesh Patra - avatar