Develop two algorithms (one iterative and one recursive) to print the daily salary of a worker who, each day, is paid twice the previous day's salary (starting with one penny for the first day's work) for a 30 day period.
What problems are you likely to encounter if you implement your solutions on an actual machine?© BrainMass Inc. brainmass.com October 10, 2019, 1:31 am ad1c9bdddf
Following two algorithms have been expressed in C-style pseudocode.
function iterativeWay ()
// For the first day salary is 1 penny.
salaryForDay = 1
day = 1
while (day <= 30)
print day, " - ", salaryForDay;
// Be ready for next iteration/day
day = day + 1
salaryForDay = 2 * salaryForDay
function recursiveWay (day, salaryForDay)
if (day <= 30)
print day, " - ", ...
Algorithms have been expressed in C-style pseudo-code.