an old arabic has it that a fabolously wealthy but unthinking king agreed to givea beggarone cent and double the amount for 64 days. using this information,write, run and test a c++ program that display how much the king must pay the beggar on each day. the output of your program should appear as follows
day amount owed
--- -----------
1 0.01
2 0.02
3 0.04
. .
. .
. .
64 .
b. modify the program you wrote for exercise 10a to determine on which day the king will have paid to the beggar a total of one million dollars.
#include <string>
#include <iostream>
using namespace std;
int main()
{
& double t=0.01,c;
for (int i=1;i<65;i++){
t*=2;
& cout<<i<<" quot;<<t<<"\n";& }
cout<<"\n\n";
system("PAUSE");
}
//b)
#include <string>
#include <iostream>
using namespace std;
int main()
{
& double t=0.01;
int c;
for (int i=1;i<65;i++){
t*=2;
& if (t>1000000){
& c=i;
& i=66;
}
}
cout<<c;
cout<<"\n\n";
system("PAUSE");
}
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!