C Program to Calculate Compound Interest

In this example, We will calculate Compound Interest. For calculating compound interest formula given below

Program to calculate compound interest in c

#include<stdio.h>
#include<math.h>
void main()
{
  int p,t;
  float r,ci;
  printf("Enter Principal Amount");
  scanf("%d",&p);
  printf("Enter Rate of Interest");
  scanf("%f",&r);
  printf("Enter time in years");
  scanf("%d",&t);
  ci = p * pow((1+r/100),t);
  printf("Compound Interest = %.2f",ci);
}

Output

Enter Principal Amount
1000
Enter Rate of Interest
5
Enter time in years
2
Compound Interest = 1102.50

Explanation

In this program we have used a new header file math.h Because we used a pow() function which is written in math.h header file.

Share in a Single Click

Leave a Reply

Your email address will not be published. Required fields are marked *