Thursday, December 28, 2017

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.

#include <iostream>
using namespace std;

int main()
{
    double product = 1; // otherwise it'll all be 0
    double n;
    double sum;

    cout << "Enter a number:\t";
    cin >> n;

    while (product <= n)
        product *= 10;

        for (double i = 0; i < n; i++)
        {
            product*10;
        }

        cout << n << " is smaller than the number " << product << endl;

            do {

                product *= 10;
                cout << "So is: " << product << endl;

            } while (product < 1000);

    return 0;

}

No comments:

Post a Comment