Question #35987

A child's parents promised to give the child $10 on her 12th birthday and double the gift on every subsequent birthday until the annual gift exceeded $1000. Write a c++ program to determine how old the child will be when the last amount is given and the total amount the child will have received.

Expert's answer

#include <iostream>
using namespace std;
int main()
{
    int year = 12,
        value = 10,
        total = 0;
    do
    {
        year++;
        value *= 2;
        total += value;
    }
    while(value*2 < 1000);
    cout << "Age: " << year << endl;
    cout << "Last gift: " << value << endl;
    cout << "Total: " << total << endl;
    cin.get();
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS