while and do-while Loops

Exercises

  1. Write a program that reads in a number n. Then it should write out the first power of number 10 that is greater than number n. The powers of number 10 are: 1, 10, 100, 1000, 10000, and so on.
  2. Write a program that reads in a number n. Then it should write out all the powers of number 10 that are smaller than the number n.

Click here for solutions

More exercises are available in the printed edition.