calculate compound interest

// CI = principle * pow((1 + rate / 100), time)
#include<stdio.h>
#include<math.h>
int main()
{
      float principle, time, rate, CI;
      scanf("%f", &principle);
      scanf("%f", &time);
      scanf("%f", &rate);
      CI = principle* (pow((1 + rate / 100), time));
      printf("Compound Interest = %f", CI);
    return 0;

}
Input:
5000
2
2.6
Output:
Compound Interest = 5263.380371
Compound Interest = 1333.099243

No comments:

Post a Comment