I've been doing well in this darn class up until this assignment. oh well, this is my first class and i'm only 5 weeks in. anyway, here is the program specifics:
Suppose you invest $100.00 at an interest rate of 10% per year. The interest is computed at the end of each day, and is added to your account (i.e., the interest is compounded daily). Print what the account value will be at the end of each year for 20 years. Use data type double for money. Assume 365 days per year, hence the daily interest rate is 10 / 365. Do not use the pow function.
This is what I have so far:
I thought I had a decent understanding of the for loop, but now I feel like I'm missing it. How I tried to write this was having a for loop inside a yearly for loop that performed the daily compound for a year and then after that cycle it would print. Do for loops require more than just a simple printf statement? I feel like I am close, but who really knows. The restriction of not using the pow function makes it tricky. I haven't developed the intuition yet I suppose. Any help is appreciated.Code:double principal = 100.00; int day, year; double rate = .01* (10/365); printf("Year\tAmount on deposit ($)\n"); for(year = 1; year < 20; year++); { for(day = 1; day <= 365; day++); { principal += (principal * rate); } printf(" %d\t\t%.2f \n", year, principal); }