Answer to Question #50622 in C++ for Hania

Question #50622
An old Arabian legend has it that a fabulously wealthy but unthinking king agreed to give a beggar one cent and double the amount for 64 days. Using this information, write, run, and test a C++ program that displays 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 .
1
Expert's answer
2015-02-03T12:09:57-0500
#include <iostream>
#include <stdlib.h>
using namespace std;
int main(int argc, char *argv[])
{
double amount=0.01;
cout<<1<<" "<<amount<<endl;
for(int i=2; i <65; i++)
{
amount *= 2;
cout<<i<<" "<<amount<<endl;
}
system&#40;"PAUSE"&#41;;
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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS