C program to find compound interest is a simple mathematical equation solving implementation in the c program.

What is compound interest?
Compound interest is calculated on initial the principal amount and also interest on the investment of previous periods of the loan.
The value compound is reinvesting the interest, rather than paying it out.

Compound interest formula
Compound interest = Principal((1+rate/n)^(n*time))
Where the principal is the principal amount to be invested
Rate is a rate of interest
N is no of days amount investment
Times is number of time compounded

Example :-
Principal = 5000, Rate = 5, No of year = 10, Times = 12
Compound interest =Principal((1+rate/n)^(n*time))
Compound interest = 8235.04

Algorithm to calculate compound interest

  1. Declare variables
  2. Take inputs from user principal, rate, no, and times
  3. Calculate compound interest using formula.
    Compound interest =Principal((1+rate/n)^(n*time))
  4. Print Compound interest

C program to find compound interest

#include<stdio.h>

#include<math.h>

main()

{

//CI=P((1+r/n)^(nt))

float compoundInterest,principal,rate,time;

int n;

printf("Enter Principal\n");

scanf("%f",&principal);

printf("Enter rate in percentage\n");

scanf("%f",&rate);

printf("Enter time in years(demcimals)\n");

scanf("%f",&time);

printf("Enter number of times interest is compounded per year\n");
scanf("%d",&n);


compoundInterest=(float)(principal*(pow((1+(rate/(100*n))),(n*time))));

printf("Compound Interest is %f\n",compoundInterest);

}

Output :

C program to find compound interest

Write A Comment