what is the difference between while and if statement?
Well the if is a one time branching operation and the while loop is as the name implies a loop. Meaning an if statement gives you once the possibility to do something or not (or something else). Whereas a while loop does things as long as the condition is true.