0
i cant stop the loop
<?PHP $p=24000000; $y=1990; $r=0.035; $ny=$y++; $count=1; while($p<50000000){ $np=$p+($p*$r); $y=$y+1 /*calculate the rate of growth of population in a year*/; echo "iteration # $count.<h5>thepopulation willbe<em>$np</em>ni year<u>$y</u></h5>"/; $count++;} echo "<br/><br/><h2>the populatuon will be<Mem>$np</em>in year <u>$y</u></h2>"/*print the year that the population reached 50000000 and stop*/ ; ?> WHY DOES'NT IT STOP
6 Answers
+ 9
You haven't changed $p inside the loop if I'm seeing right. So $p will remain less than 50000000 forever and loop will run đ forever :)
+ 3
The same, $p not appear into while and always have the same initial value
+ 2
what is $p and what is $np? if you use $p for the while then you must to write something to increase to arrive sometime to break condition
+ 1
Maybe you must to fix
$np=$p+($p*$r)
per
$p=$p+($p*$r)
0
so what should I change