Best program to calculate compound interest
CODE:-
#include <stdio.h>
int main()
{
int p,t;
float i,r,a;
printf("Enter the principle amount.");
scanf("%d",&p);
printf("Enter the rate: ");
scanf("%f",&r);
printf("Enter the total time taken: ");
scanf("%d",&t);
for(int j=1;j<=t;j++)
{
i=p*r/100;
a=i+p;
p=a;
printf("Amount after %d years= %f\n",j,a);
}
printf("*******Total amount to paid= %f*******",a);
return 0;
}
Comments
Post a Comment