Wednesday, 10 April 2013

Simple Interest and Compound Interest Calculation

Share it Please


Aim:
To write a ‘C’ program to find the simple interest and Compound interest for the Amount (P), Rate of Interest (R) and Number of years (N)

Algorithm:
1.      Read Principal (P), Rate of Interest (R) and Number of years (N).
2.      Calculate Simple Interest (SI) and Compound Interest using the formula
              SI=(P*N*R)/100
              CI=P * ((1+R)/100)^N –P
3.      Display the result.
4.      Stop

Program:
/* Program to calculate Simple Interest and Compound Interest */
#include<conio.h>
#include<stdio.h>
#include<math.h>               // For pow function
void main()
{
          double p,n,r,si,ci,x;
          clrscr();
          printf("Enter the principal:Rs ");
          scanf("%lf",&p);
          printf("Enter rate of interest:");
          scanf("%lf",&r);
          printf("Enter number of years:");
          scanf("%lf",&n);
/* To calculate Simple Interest*/
          si=p*n*r/100;
/* To calculate Compound Interest*/
          ci=pow((1+r/100),n)*p-p;

/* Display the result*/
          printf("\n\nSimple interest =Rs %.2lf\n\n",si);
          printf("Compound Interest =Rs %.2lf",ci);
          getch();
}
Output:
Enter the principal:Rs 2000
Enter rate of interest:2
Enter number of years:3
Simple interest =Rs 120.00
Compound Interest =Rs 122.42

                      



No comments:

Post a Comment

Blogroll

About

Designed By IAMNGP | Moon