Wednesday, 23 April 2014

10. Write a function that calculates the compounded interest amount for a given initial amount, interest rate and number of years. The interest is compounded annually. The return value will be the interest amount. Use the following function definition: float comp_int_calc( float int_amt, float rate, int years); Write a program that will accept the initial amount, interest rate and the number, of years and call the function with these values to find out the interest amount and display the returned value.



#include<stdio.h>
#include<conio.h>
float interest(float int_amt,float rate, int year);
void main()
{
          int int_amt,year;
          float rate,amt;
          clrscr();
          printf("\n\n\t Enter the Principle Amt.-> ");
          scanf("%d",&int_amt);
          printf("\n\n\t Enter the Rate of Interest -> ");
          scanf("%f",&rate);
          printf("\n\n\t Enter the No. of Years -> ");
          scanf("%d",&year);
          amt=interest(int_amt,rate,year);
          printf("\n\n\t\tYour compound Interest is %f",amt);
          getch();
}
float interest(float int_amt,float rate, int year)
{
          float interest,amt,ci;
          float i,j=1;
          for(i=1; i<=year; i++)
          {
                   j=(rate+100)/100*j;
          }
          interest=int_amt*j;
          ci=int_amt+interest;
          return ci;
}

No comments:

Post a Comment