63 844
Assignments Done
99,2%
Successfully Done
In August 2018

Answer to Question #67122 in C for Jcullen

Question #67122
An old Arabian legend has it that a fabulously wealthy but unthinking king agreed to give a beggar 1 Shilling and triple the amount for 10 days. Using this information, write, compile, and run a C program that displays how much the king must pay the beggar on each day and the total earned by the beggar at the end of the 10day period. The output of your program should appear as follows:
Day Amount Owed Running total earned
1 1 1
2 3 4
3 27 31
. .
. .
10.
Expert's answer
#include <stdio.h>

int main()
{
int i, amountOwed = 1, totalEarned = 1;
printf("Day Amount Owed Running total earned\n");
for (i = 0; i < 10; ++i)
{
printf("%3d %13d %22d\n", i + 1, amountOwed, totalEarned);
amountOwed *= 3;
totalEarned += amountOwed;
}
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

jcullen
04.04.17, 21:07

The site I been so far and am fully satisfied with the services.

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions