The while statement or loop will execute a block of code while a given condition is true.
Syntax
while (variable<=endvalue) { //code block to be executed }
Note: The <= could be anything that would fit the purpose ex. >, == or whatever.
The while loop sets x equal to 0. As long as x is less than temp, the loop will continue to run. x will increase by 1 each time the loop runs.