#include <stdio.h>
#include <math.h>

int main() {
    int p, t, n;
    float r, compound_interest;

    printf("Enter P (initial principal balance): \n");
    scanf("%d", &p);

    printf("Enter r (interest rate): \n");
    scanf("%f", &r);

    printf("Enter n (number of times interest applied per time period): \n");
    scanf("%d", &n);

    printf("Enter t (number of time periods elapsed): \n");
    scanf("%d", &t);

    compound_interest = p * pow((1 + (r / n)), (n * t)) - p;

    printf("Compound Interest is: %.2f\n", compound_interest);

    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: