×

C Programs

C Basic & Conditional Programs

C Looping Programs

C String Programs

C Miscellaneous Programs

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

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

Compound Interest Formula

The formula to get compound interest is:

compound_interest=principal*((1+rate/100)time-1)

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

    ci = principal * ((pow((1 + rate / 100), year) - 1));

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

    return 0;
}

Output

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

C Advance Programs »

Related Programs

Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.