65 721
Assignments Done
99,2%
Successfully Done
In October 2018

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 .
Expert's answer
#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 first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions