C Program to find Compound Interest

C Program to find Compound Interest

The program asks user to enter value of principle (p), rate (r) and time (t) and finally calculates the compound interest by following formula.

Write a C program to input principle (amount), time and rate (P, T, R) and find Compound Interest. How to calculate compound interest in C programming. Logic to calculate compound interest in C program.

#include<stdio.h>
#include<conio.h>
void main() 
{
    float p, r, t, comp;

    printf("Enter the principle :");
    scanf("%f", &p);
    printf("Enter the rate :");
    scanf("%f", &r);
    printf("Enter the time :");
    scanf("%f", &t);

    comp = p * pow((1 + r / 100), t) - p;

    printf("\nThe compound interest is %0.2f", comp);
 
   getch();
}
 

Output

  1. You can see here. First of all the Header File Structure of the C Program has been created.
  2. After that Main() Function is written.
  3. float p, r, t, comp These variables have been created. In which the data is stored
  4. calculate variable comp created. Whose value is p * pow((1 + r / 100), t) – p
  5. printf(“\nThe compound interest is %0.2f”, comp);
TOP