The while statement will execute a block of code as long as test expression is true.
If the test expression is true then the code block will be executed. After the code has executed the test expression will again be evaluated and the loop will continue until the test expression is found to be false.
while(condition) { code to be executed; }
Loop stopped at i =1 and num = 40