Index « Previous Next »

Question

Write a program which prompts the user to input principle, rate and time and calculate compound interest. The formula is :
CI = P(1+R/100)T - P.

Source Code

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

int main()
{
    float p, r, t, ci;

    printf("Enter the principle :");
    scanf("%f", &p);
    printf("Enter the rate :");
    scanf("%f", &r);
    printf("Enter the time :");
    scanf("%f", &t);

    ci = p * pow((1 + r / 100), t) - p;

    printf("\nThe compound interest is %0.2f", ci);

    return 0;
}

Output

Enter the principle :5400
Enter the rate :8
Enter the time :3

The compound interest is 1402.44