Common Computer Science References
At the end of this lesson, you will be able to:
understand and use a loop statement with if statements
boolean expressions
can you combine an if statement inside a loop, YES
you can make an "infinite" loop by: while (true) {
you can exit an infinite loop by: break
nil
create a program, using a loop and an if statement, that:
it does long division on 2 positive integers, while simplified long division
keep subtracting until the number you are left with is smaller that the number you are dividing by and then break and show the remainder
Example:
7 / 2
7 -2 = 5 ☚ first time
5 - 2 = 3 ☚ second time
3 - 2 = 1 ☚ third time (break)
therefore 7 / 2 = 3 R 1
do the above program in PHP