Write code to complete DoublePennies()'s base case. Sample output for below program with inputs 1 and 10: Number of pennies after 10 days: 1024 Note: If the submitted code has an infinite loop, the...


Write code to complete DoublePennies()'s base case. Sample output for below program with inputs 1 and 10:


Number of pennies after 10 days: 1024


Note: If the submitted code has an infinite loop, the system will stop running the code after a few seconds, and report "Program end never reached." The system doesn't print the test case that caused the reported message





#include


// Returns number of pennies if pennies are doubled numDays times
long long DoublePennies(long long numPennies, int numDays){
long long totalPennies;


/* Your solution goes here */


else {
totalPennies = DoublePennies((numPennies * 2), numDays - 1);
}


return totalPennies;
}


// Program computes pennies if you have 1 penny today,
// 2 pennies after one day, 4 after two days, and so on
int main(void) {
long long startingPennies;
int userDays;


scanf("%lld", &startingPennies);
scanf("%d", &userDays);
printf("Number of pennies after %d days: %lld\n", userDays, DoublePennies(startingPennies, userDays));


return 0;
}



Jun 05, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here