Ruby while loop is used to iterate a program several times. If the number of iterations is not fixed for a program, while loop is used.