Program 175:
Formula for CI:
Output:
#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))
- 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
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 usercompoundInterest=(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:


