+ 1

why the output of the following program is 147?

$x=1; while ($x<10){ echo $x; $x=$x+3; } please explain a little bit.

26th Jul 2017, 5:46 AM
Md. Jahid Hasan
Md. Jahid Hasan - avatar
1 Odpowiedź
+ 9
x >=1 and less than 10 and your algorithm adds 3 to each value of x thus: when x ->1 x~1+3 ->4 when x=4 x~4+3 ->7 ...so x=147
26th Jul 2017, 6:09 AM
Nomeh Uchenna Gabriel
Nomeh Uchenna Gabriel - avatar