4. Write the program for the simple, compound interest.
#include<stdio.h>
#include<math.h>
void main()
{
int n;
float p,q,r,SI=0,CI=0;
clrscr();
printf("\n Enter the value of Principal p = ");
scanf("%f",&p);
printf("\n Enter the value of Rate r = ");
scanf("%f",&r);
printf("\n Enter the value of Period in year n = ");
scanf("%d",&n);
SI = ((p*r*n)/100);
printf("\n Simple Interest SI=%f \n",SI);
q = 1+(r/100);
CI=p*pow(q,n)-p;
printf("\n Compound Interest CI=%f \n",CI);
getch();
}
#include<math.h>
void main()
{
int n;
float p,q,r,SI=0,CI=0;
clrscr();
printf("\n Enter the value of Principal p = ");
scanf("%f",&p);
printf("\n Enter the value of Rate r = ");
scanf("%f",&r);
printf("\n Enter the value of Period in year n = ");
scanf("%d",&n);
SI = ((p*r*n)/100);
printf("\n Simple Interest SI=%f \n",SI);
q = 1+(r/100);
CI=p*pow(q,n)-p;
printf("\n Compound Interest CI=%f \n",CI);
getch();
}
OUTPUT:
Enter the value of Principal p = 3500
Enter the value of Rate r = 4
Enter the value of Period in year n = 2
Simple Interest SI=280.000000
Compound Interest CI=285.599731
Comments
Post a Comment