#include <stdio.h>
#include <conio.h>
#include <math.h>
#define N 3
int main()
int i,j;
float irate,investment,curInterest,curInvest,totInterest=0.0; //variable declaration
float getIntRate(); //function declaration
float getAmount();
float findInterest(float amt, float irate);
irate=getIntRate(); //get the interest rate from keyboard
investment=getAmount(); //get the investment amount from keyboard
curInvest=investment; //set the current investment
for(i=1;i<=N;i++) //loop starts upto N years
printf(“Year : %dn”, i); //print the heading
printf(“————————nn”);
printf(“tQuarter Balance Interest Total Interest Totaln”);
printf(“t=================================================================n”);
for(j=1;j<=4;j++) //number of terms
curInterest=findInterest(curInvest,irate); //find the interest rate for the current quarter
totInterest+=curInterest; //update the total interest
printf(“t%dt%.2ftt%.2ftt%.2ftt%.2fnn”,j,curInvest, curInterest,totInterest,(curInvest+curInterest)); //print the interest details
curInvest=curInvest+curInterest; //update the final total
system(“pause”); //wait the keyboard response from user
return 0;
float findInterest(float amt, float irate)
float interest;
interest= (amt * irate) /400.0; //find the interest
return interest;
float getIntRate()
float interest;
while(1)
printf(“Enter the interest rate : “);
scanf(“%f”,&interest); //read the interest rate
if(interest>=5 && interest<=20) //check if the interest rate between 5 and
break; //if the above condition is true, exit from the loop
else
printf(“nInvalid interest rate. It should be between 5 and 20n”); //else print the error message
return interest; //return the interest value
float getAmount()
float inv;
while(1
printf(“nEnter the Investment Amount : “);
scanf(“%f”,&inv); //read the investment amount
if(inv>0) //if the investment amount is greater than zero, if yes, exit from the loop
break;
else
printf(“nInvalid investment amount. It should be greater than 0n”); //otherwise, print the error message
return inv;