C program to calculate compund interest

In this example, we will calculate compound interest based on user input.

Calculate Compound Interest In C Programming

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

int main()
{
    float principle, rate, time, CI;

    printf("Enter principle (amount): ");
    scanf("%f", &principle);

    printf("Enter time: ");
    scanf("%f", &time);

    printf("Enter rate: ");
    scanf("%f", &rate);

    CI = principle* (pow((1 + rate / 100), time));

    printf("Compound Interest = %.2f", CI);

    return 0;
}
    

Output :

	
Enter principle (amount): 1000
Enter time: 2
Enter rate: 5
Compound Interest = 1102.50
	

Share your thoughts

Ask anything about this examples