4.2.9 iterations
<?php
$a = 10;
$b = 0 ;
if ($a > $b) {
$a = $b - 3;
while ( $a < $b ) {
print "loop1" ;
$b = $a*2;
while ( $b > 7) {
$b = $a - 2 ;
print "loop3" ;
}
print "loop 2" ;
}
}
?>
Before Running Program record your answers to questions below
Q1. What is going to be the output when a=10 and b=4?
Q2. What is going to be the output when a=4 and b=10?
Q3. What is going to be the output when a=10 and b=0?
Q4. What is going to be the output when a=10 and b=9?
Import program and set $a and $b and run to check your answers
Challenge A
Write an algorithm that finds the two neighboring numbers in an array with the smallest distance to each other. The program should output the distance, index of the first number and the index of the second number. For example, in the array A = [5 , 1 , 4 , 7 , 9 , —12] the minimum distance is 2 (between array element 3 and 4). This algorithm should return: distance 2 between element 3 and element 4.
Useful Information: In this problem the use of a function that returns the absolute ‘. value of a number is essential. According to the IBO document Pseudo code in : Examinations, Standard Data Structures and Examples of Pseudo code: “If such a E specialized method is to be used in an examination, it will be fully specified as part of : the question in which it is needed."
First lines of code to get started ( try writing in pseudo code first )
$A = [5,1,2,7,9,-12];
$SIZE = 6;
$MINIMUM = (abs($A[0] - $A[1]));
$MININDEX = 0;