diff --git a/C/compound_interest.c b/C/compound_interest.c new file mode 100644 index 0000000..179a2ad --- /dev/null +++ b/C/compound_interest.c @@ -0,0 +1,23 @@ +#include +#include + +int main(void){ + double principal, rate, amount; + int years, i; + + printf("Enter the principal: "); + scanf("%lf", &principal); + printf("Enter the rate: "); + scanf("%lf", &rate); + printf("Enter the number of years: "); + scanf("%d", &years); + + printf("Year\tAmount on deposit \n"); + + for (i = 1; i <= years; i++){ + amount = principal * pow(1 + rate, i); + printf("%d\t%.2f \n", i, amount); + } + + return 0; +} \ No newline at end of file