The power of compounding against simple interest practically with coding|| c programming to print compound interest || program to calculate compound interest, compound amount, simple interest, simple amount
The power of compounding against simple interest practically with coding|| c programming to print compound interest || program to calculate compound interest, compound amount, simple interest, simple amount :
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
float compoundamount(float principle, float rate, float time)
{
float CA;
CA = principle * ((pow((1 + rate / 100), time)));
return CA;
}
float compoundinterest(float principle, float rate, float time)
{
float CI;
CI = principle * ((pow((1 + rate / 100), time)) — 1);
return CI;
}
float simpleinterest(float principle, float rate, float time)
{
float SI;
SI = (principle * rate * time) / 100;
return SI;
}
float simpleamount(float principle, float rate, float time)
{
float SA;
SA = principle + (principle * rate * time) / 100;
return SA;
}
int main(void)
{
float pa, r, tp;
float simpleInterest, simpleAmount, compoundAmount, compoundInterest;
printf(“Enter principle amount: “);
scanf(“%f”, &pa);
printf(“Enter rate amount: “);
scanf(“%f”, &r);
printf(“Enter time: “);
scanf(“%f”, &tp);
printf(“\n\n\n\t\t\t Comparison”);
printf(“\n\n\tSimplified result\t\tCompounded result”);
simpleInterest = simpleinterest(pa, r, tp);
compoundAmount = compoundamount(pa, r, tp);
compoundInterest = compoundinterest(pa, r, tp);
simpleAmount = simpleamount(pa, r, tp);
printf(“\nsimpleInterest: %.3f\t\tCompound Interest: %.3f”, simpleInterest, compoundInterest);
printf(“\nsimpleAmount: %.3f\t\tCompound Amount: %.3f”, simpleAmount, compoundAmount);
return 0;
}
Here is the program:
thanks you