0
6.1kviews
Write a program to calculate compound interest and amount using formula A=P(1+R/100)n where P= Principal amount, R= Rate of interest, n=number of years.

Mumbai University> FE > Sem 2> STRUCTURED PROGRAMMING APPROACH

Marks: 10 M

Year: May 2016

1 Answer
0
256views
#include<stdio.h>
float power(float base, float n);
main()
{
float CIA, P, R, n,CIY;
int i;
printf(“Enter Principal Amount:”);
scanf(“%f”,&P);
printf(“Enter rate of interest:”);
scanf(“%f”&R);
printf(“Enter number of years:”);
scanf(“%f”,&n);
CIA=P*power((1+R/100),n);
printf(“Total Compound interest and amount is %f”,CIA);
for(i=1;i<=n;i++)
{
    CIY=P*((1+R/100),i)-P;
    printf(“\nTotal interest at the end of year %d is %f ”,i,CIA)
}
}

float power(float base, float n)
{
int i,pow;
pow=1;
for(i=1;i<=n;i++)
{
p=p*base;
}
return p;
}

Output:
Enter Principal Amount: 1200
Enter rate of interest: 11
Enter number of years: 5
Total Compound interest and amount is 2022.07
Total interest at the end of year 1 is 132
Total interest at the end of year 2 is 278.52
Total interest at the end of year 3 is 441.16
Total interest at the end of year 4 is 621.68
Total interest at the end of year 5 is 822.07
Please log in to add an answer.