Program to calculate Compound Interest

The following C Program is to Calculate Compound Interest.In this, p is principal amount, t is time, r is rate of interest and amt is total amount and ci is compound interest

#include<stdio.h>

#include<conio.h>

#include<math.h>

void main()

{

/* variable declaration part */

int p,t;

float r,amt,ci;

 

clrscr();

 

printf(“Enter Principal Amount -> “);

scanf(“%d”,&p);

printf(“Enter Time            -> “);

scanf(“%d”,&t);

printf(“Enter Rate of interest-> “);

scanf(“%f”,&r);

amt= p*pow((1+r/100),t);  //pow is inbuilt function

ci = amt-p;

printf(“\nSimple interest  :-> %7.2f \n”,ci);

printf(“Total amount     :-> %7.2f \n”,amt);

getch();

}

 

Mohit Arora
Follow me