The main difference between an if and a while statement is that an if statement gives you the opportunity to branch the execution of code once based on a condition. The code in the if block is only executed once. For instance, if a value is greater than another, an if statement will branch out and execute a computation, and then proceed with the program's flow or exit.
A while statement, however, gives you the opportunity to run a block of code multiple times as long as a condition evaluates to true. This means that a while statement will, for example, execute a computation as long as value A is greater than value B and only proceed with the program flow when A is no longer greater than B.
In this sense, a while statement can be considered a loop. We'll look at looping structures next.