Solutions
7. while and do-while Loops
Exercise 1:
#include <iostream> using namespace std; int main() { cout << "Enter a number N: "; double n; cin >> n; double power=1; while(power<=n) { power*=10; } cout << "The first power of ten greater than N is: " << power << endl; }
Exercise 2:
#include <iostream> using namespace std; int main() { cout << "Enter a number N: "; double n; cin >> n; double power=1; while(power<n) { cout << power << endl; power*=10; } }