Write a programm To calculate simple and compound interest, given principle, rate and time in C.



Write a programm To calculate simple and compound interest, given principle, rate and time in C.

 

#include<stdio.h>
#include<math.h>
void main()
{
  float p, t;/*p is principle in Rs, r is rate in %, t is time in years */
  float r, si, a, ci;   /* ci is compound interest, a = amount of ci */
  clrscr();
  printf("Program to calculate simple and compound interest\n\n");
  printf("Please enter Principle, Rate, and Time(separated by a blank each)\n");
  scanf("%f %f %f", &p, &r, &t);
  si = p * r * t / 100;           /* si is simple interest */
  a  = p * pow((1 + (r / 100)), t); /* pow is raised to function */
  ci = a - p;
  printf("\nThe simple interest   = %.2f Rs.\n", si);
  printf("\nThe compound interest = %.2f Rs.\n\n", ci);
  printf("Job over...Press any key to continue "); getch();
}

Labels: