Exercise 6: While loop

A while loop repeats code until the condition is met. Unlike for loops, the number of iterations in it may be unknown.  A while loop always consists of a condition…