EX.
NO: 1 SIMPLE INTEREST AND COMPOUND INTEREST
DATE:
AIM
To write C program to calculate simple interest and compound interest.
ALGORITHM
Start
Read Principal Amount(p), No. of years(n) and Rate of Interest(r)
Calculate Simple Interest using formula SI=(p*n*r)/100;
Calculate Compound Interest using formula
ci = p * (pow(1 + r / 100, n) - 1);
Print Simple Interest and Compound Interest
Stop
PROGRAM:
#include <stdio.h>
#include <math.h>
#include <conio.h>
void main()
{
float p, t, r, si, ci;
clrscr();
printf("Enter principal amount (p): ");
scanf("%f", &p);
printf("Enter duration in years (n): ");
scanf("%f", &n);
printf("Enter rate of Interest (r): ");
scanf("%f", &r);
si = (p * n * r) / 100.0;
ci = p * (pow(1 + r / 100, n) - 1);
printf("\n Simple Interest = %.2f ", si);
printf("\n Compound Interest = %.2f ", ci);
getch();
}
Result:
Thus, the C program to calculate simple interest and compound interest was
executed successfully.