60 689
Assignments Done
97,9%
Successfully Done
In April 2018

Answer to Question #50629 in C++ for Ash

Question #50629
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 <stdio.h>
using namespace std;
int main() {
    float amount = 0.005;
    printf("Day  Amount Owed\n");
    printf("---  -----------\n");
    for (int i = 1; i <= 64; i++) {
        amount *= 2;
        printf("=  %.2f\n", i, amount);
    }
    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