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 timeslong 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 onint 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;}
// Returns number of pennies if pennies are doubled numDays timeslong 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 onint 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;}
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here