After the two integer values have been entered and stored in the variables u and v (using the %u format characters to read in an unsigned integer value), the program enters a while loop to calculate their greatest common divisor. After the while loop is exited, the value of u, which represents the gcd of v and of the original value of u, is displayed with an appropriate message.
You will use the algorithm for finding the greatest common divisor again in Chapter 7, “More on Classes,” when you return to working with fractions. There you will use the algorithm to reduce a fraction to its simplest terms.
For the next program that illustrates the use of the while statement, let’s consider the task of reversing the digits of an integer that is entered from the terminal. For example, if the user types in the number 1234, the program should reverse the digits of this number and display the result of 4321.