Skip to content

PRO TIP Block youtube.com at the DNS level โ€” Pi-hole, NextDNS or your hosts file โ€” but allow youtube-nocookie.com and i.ytimg.com. These tutorials keep playing; the rabbit hole does not.

Learning without distractions

Let’s code an interest calculator with C programming! ๐Ÿ’ฐ

13.2K views on YouTube

#coding #programming #cprogramming

// COMPOUND INTEREST CALCULATOR

double principal = 0.0;
double rate = 0.0;
int years = 0;
int timesCompounded = 0;
double total = 0.0;

printf(“Compound Interest Calculator\n”);

printf(“Enter the principal (P): “);
scanf(“%lf”, &principal);

printf(“Enter the interest rate % (r): “);
scanf(“%lf”, &rate);
rate = rate / 100;

printf(“Enter the # of years (t): “);
scanf(“%d”, &years);

printf(“Enter # of times compounded per year (n): “);
scanf(“%d”, &timesCompounded);

total = principal * pow(1 + rate / timesCompounded, timesCompounded * years);

printf(“After %d years, the total will be $%.2lf”, years, total);

return 0;