 ### Program 175:To Calculate Compound Interest

Program 175:

```#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);

}

```
Explanation:
Formula for CI:
`CI=Principal((1+rate/n)^(n*time))`
1. We used
• principal → To store principal in Rupees
• rate → To store rate in %
• time → To store time in years
• n To store number of times interest is compounded per year
• compoundInterest → To store output
2. ```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);```
Taking all the required variables as input from user
3. ```compoundInterest=(float)(principal*(pow((1+(rate/(100*n))),(n*time))));
printf("Compound Interest is %f\n",compoundInterest);```
compoundInterest is calculated by using formula and is then printed.

Output: 