Calculate Simple and Compound Interest

Get the Principal Amount , Time Period and Rate of Interest from the user and calculate and print the simple and compound interest.

/*
Calculate Simple and Compound Interest
Shaswat Saxena
10/11/2017
*/
#include <stdio.h>
#include <conio.h>
#include <math.h>
void main()
  {
  float p,r,t,si,ci,sia,cia;
  clrscr();
  printf("Enter the Principal Amount Deposited\n");
  scanf("%f",&p);
  printf("Enter the Rate of Interest \n");
  scanf("%f",&r );
  printf("Enter the Time in years\n");
  scanf("%f",&t );
  si=(p*r*t)/100;
  sia=p+si;
  cia=p*pow((1+r/100),t);
  ci=cia-p;
  printf("The Simple Interest is = %f and amount is %f\n",si,sia);
  printf("The Compound Interest is = %f and amount is %f\n",ci,cia);
  getch();
}

Output

Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for subscribing.

Something went wrong.

Recommended for You  Sort numbers using Bubble Sort

Leave a Reply

Close Menu