Monday, June 18, 2012

To calculate simple interest and compound interest

/* To calculate simple interest and compound interest */
#include<stdio.h>

#include<conio.h>

#include<math.h>

void main()

{

 int p,t,n;

 float r,si,ci;

 clrscr();

 printf("Enter the principal amount: ");

 scanf("%d",&p);

 printf("\nEnter the rate of interest: ");

 scanf("%f",&r);

 printf("\nEnter the time period: ");

 scanf("%d",&t);

 printf("\nEnter the compounding per period: ");

 scanf("%d",&n);

 /* To calculate simple interest */

 si = p*r*t/100.00;

 /* To calculate compound interest */

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

 printf("\n\nSimple Interest=%f",si);

 printf("\nCompound Interest=%f",ci);

 getch();

}

 

OUTPUT

Enter the principal amount: 5000

Enter the rate of interest: 3.4

Enter the time period: 2
 
Enter the compounding per period: 1


Simple Interest=340.000000

Compound Interest=345.779999

 
 

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.