Calculation of compound interest:
Compound interest arises when interest is added to the principal, so that from that moment on, the interest that has been added also earns interest. This addition of interest to the principal is called compounding. For example,for Rs 1000 interest compounded every year at 20% interest per year would have a balance of Rs 1200 at the end of the first year, Rs. 1440 at the end of the second year, and so on.
// write a c program to calculate compound interest
// C program to calculate compound interest
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float p,t,r;
float i,ci,a;
clrscr();
printf("enter the principal:\t");
scanf("%d",&p);
printf("enter the rate of interest:\t");
scanf("%d",&r);
printf("enter the time in years:\t");
scanf("%d",&t);
if((p<1)||(t<1)||(r<1))
printf("invalid");
else
{
i=(p*t*r)/100.0;
printf("the compound interest is rs.%.2f",i);
a=(float)p*(pow(1+r/100.0,t));
ci=a-p;
printf("the compund int is rs.%.2f",ci);
}
getch();
}
Compound interest arises when interest is added to the principal, so that from that moment on, the interest that has been added also earns interest. This addition of interest to the principal is called compounding. For example,for Rs 1000 interest compounded every year at 20% interest per year would have a balance of Rs 1200 at the end of the first year, Rs. 1440 at the end of the second year, and so on.
// write a c program to calculate compound interest
// Calculate compound interest in / using c program
// C program to calculate compound interest
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float p,t,r;
float i,ci,a;
clrscr();
printf("enter the principal:\t");
scanf("%d",&p);
printf("enter the rate of interest:\t");
scanf("%d",&r);
printf("enter the time in years:\t");
scanf("%d",&t);
if((p<1)||(t<1)||(r<1))
printf("invalid");
else
{
i=(p*t*r)/100.0;
printf("the compound interest is rs.%.2f",i);
a=(float)p*(pow(1+r/100.0,t));
ci=a-p;
printf("the compund int is rs.%.2f",ci);
}
getch();
}
No comments:
Post a Comment