ADVERTISEMENT
ADVERTISEMENT

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:

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 »


ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions


ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.