Home > Backend Development > C++ > C language formula to calculate interest amount

C language formula to calculate interest amount

PHPz
Release: 2023-09-10 18:45:05
forward
1960 people have browsed it

C language formula to calculate interest amount

Problem

Write a C program to calculate the increased interest on the deposit amount after some years

Solution

The formula for calculating interest is −

M=((r/100) * t);
A=P*exp(M);
Copy after login

Where r= rate of interest

          t=no. of years

            P=amount to be deposited

M=temporary variable

A= Final amount after interest

Algorithm

START
Step 1: declare double variables
Step 2: read amount to be deposited
Step 3: read rate of interest
Step 4: read years you want to deposit
Step 5: Calculate final amount with interest
         I. M=((r/100) * t);
         II. A=P*exp(M);
Step 6: Print final amount
STOP
Copy after login

Example

#include<stdio.h>
#include<math.h>
#include<ctype.h>
int main(){
   double P,r,t,A,M;
   printf("amount to be deposit in the bank: ");
   scanf("%lf",&P);
   printf("</p><p> enter the rate of interest:");
   scanf("%lf",&r);
   printf("</p><p> How many years you want to deposit:");
   scanf("%lf",&t);
   M=((r/100) * t);
   A=P*exp(M);
   printf("</p><p> amount after %0.1lf years with interest is:%0.2lf",t,A);
   return 0;
}
Copy after login

Output

amount to be deposit in the bank: 50000
enter the rate of interest:6.5
How many years you want to deposit:5
amount after 5.0 years with interest is:69201.53
Copy after login

The above is the detailed content of C language formula to calculate interest amount. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template