Skip to content
This repository has been archived by the owner on Nov 18, 2022. It is now read-only.

Added a C Program for Compound Interest #201

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions C/compound_interest.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <stdio.h>
#include <math.h>

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;
}