In this program we will find the compound interest from the given principal, no of years, and rate of interest, code for the program is given below.
Find the compound interest from the given Principal, No. of Years, and Rate of Interest
#include <stdio.h>
#include <math.h>
int main()
{
float p, n, r, q, a;
int count;
for (count = 1; count <= 10; count++)
{
printf("Enter principal amount\n");
scanf("%f", &p);
printf("Enter number of years\n");
scanf("%f", &n);
printf("Enter rate of interest\n");
scanf("%f", &r);
r = r / 100;
printf("Enter no of times you compound per year\n");
scanf("%f", &q);
a = p * pow((1 + (r / q)), n * q);
printf("Compounded amount is %f\n\n", a);
}
return 0;
}
Output
Enter number of years
2
Enter rate of interest
8
Enter no of times you compound per year
4
Compounded amount is 5858.295898
Read: C program to find the power ‘n’ of the given number ‘a’