NAME-Mayank Popli
ROLL NO.1324595
PROGRAM -04
[4] Write a program to calculate simple interest and compound interest considering appropriate
variables.
1] ALGORITM-
Step 1) Start
Step2) Input the variable p, t, r, S.I. ,C.I.
Step 3) Put the formula to calculate S.I. ,C.I.
S.I.=(P*r*t)/100 , C.I.=P*((1+r/100)^t-1)
Step4) Print the output
Step5) End
2]FLOWCHART-
START
Declare the variables
S.I.=(P*r*t)/100 ,
C.I.=P*((1+r/100)^t -1)
Display the output S.I.,
C.I.
Stop
3] SOURCE CODE-
#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
float p, t, r, si, ci;
clrscr();
printf("Enter principal amount (p): "); scanf("%f",
&p);
printf("Enter time in year (t): ");
scanf("%f", &t);
printf("Enter rate in percent (r): ");
scanf("%f", &r);
/* Calculating simple interest */
si = (p * t * r)/100.0;
/* Calculating compound interest */
ci = p * (pow(1+r/100, t) - 1);
printf("Simple Interest = %0.3f\n", si);
printf("Compound Interest = %0.3f", ci);
getch();
return(0);
4] OUTPUT-