A while loop repeats a block of code as long as a specified condition is true. The example shows a while loop that outputs the numbers from 1 to 10 by incrementing the variable i each time through the loop, as long as i is less than or equal to 10. The syntax of a while loop includes the while keyword followed by a condition in parentheses and a code block in curly braces.