## Write a C program to calculates the Simple Interest and Compound Interest. The Principal amount, Rate of interest and Time are entered through the keyboard:-

Here, we have to write a simple C program that calculates the Simple Interest and Compound Interest. The user will enter the Principal amount, Rate of interest, and Time.

### Formulae used:-

Simple interest=(p*r*t)/100

where, p= Principal amount

r= Rate of interest

t= Time of investment.

Compound interest= p*(1+r/100)^t (assumption taken only one-time interest got compounded annually)

## Explanation & Program code:-

We will ask the user to enter the value of the principal amount, rate of interest, and time of investment then we will store the entered value into the variables named p,r, and t respectively. Based on the entered radius value, we will calculate the simple interest and compound interest. To make the program code easier we have taken the assumption that only one-time interest gets compounded annually(in the question mentioned take the value of p, r, t from the user). Further details are mentioned as comments in the program code.

```
#include <stdio.h>
#include <math.h>
main()
{
float p,r,t,si,ci,tsi,tci; /* Decleration of variable */
printf("Enter initial amount:-");
scanf("%f",&p);
printf("Enter rate of interest per anum:-"); /*Taking input from user*/
scanf("%f",&r);
printf("Enter no of years the money is invested:-");
scanf("%f",&t);
si=(p*r*t)/100; /* Simple interest calculation*/
printf("Simple interst:-%.2f\n",si);
tsi=si+p; /*Calculation of total simple interest with principal amount*/
printf("Total amount with interest:-%.2f\n",tsi);
ci=p*pow(1+r/100,t)-p; /* Compound interest calculation*/
printf("Compound interest:-%.2f\n",ci);
tci=ci+p; /*Calculation of total compound interest with principal amount*/
printf("Total amount with compound interest:-%.2f",tci);
return 0;
}
```

### Output:-

```
Enter initial amount:-12500
Enter rate of interest per anum:-12
Enter no of years the money is invested:-8
Simple interst:-12000.00
Total amount with interest:-24500.00
Compound interest:-18449.54
Total amount with compound interest:-30949.54
```

## Algorithm of the program to calculate Simple interest and compound interest:-

## Flowchart of the program to calculate the Simple interest and Compound interest:-

As you have reached the end of the article, so I hope as of now you have a clear understanding of the program, algorithm, and flowchart to calculate the Simple interest and compound interest. Please let me know your queries, suggestion, and feedback in the comment section.