C program to calculate compound interest.

This program will read principal, rate and time in years and then print compound interest on entered principal for given time period.

Compound interest is the amount in which interest is added into the principle so that interest also can be earned interest with the principle.

The formula to get compound interest is:

Calculate Compound Interest using C program

/*C program to calculate compound interest.*/

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

int main()
    float principal, rate, year, ci;
    printf("Enter principal: ");
    scanf("%f", &principal);
    printf("Enter rate: ");
    scanf("%f", &rate);    
    printf("Enter time in years: ");
    scanf("%f", &year);

    //calculate compound interest

    printf("Compound interest is: %f\n",ci);
    return 0;

    Enter principal: 10000
    Enter rate: 10.25 
    Enter time in years: 5
    Compound interest is: 6288.943359