Program to find simple interest
What is ‘Simple Interest’?
Simple interest is a quick method of calculating the interest charge on a loan. Simple interest is determined by multiplying the daily interest rate by the principal by the number of days that elapse between payments.
Simple Interest formula:
Simple interest formula is given by:
Simple Interest = (P x T x R)/100
Where,
P is the principal amount
T is the time and
R is the rate
Examples :
EXAMPLE1:
Input : P = 10000
R = 5
T = 5
Output :2500
We need to find simple interest on
Rs. 10,000 at the rate of 5% for 5
units of time.
EXAMPLE2:
Input : P = 3000
R = 7
T = 1
Output :210
The formula to calculate the simple interest is: simple_interest = (P * T * R) / 100 where P is the principal amount, T is time & R is the rate of interest.
C++
#include<iostream>
using namespace std;
int main()
{
float P = 1, R = 1, T = 1;
float SI = (P * T * R) / 100;
cout << "Simple Interest = " << SI;
return 0;
}
|
C
#include <stdio.h>
int main()
{
float P = 1, R = 1, T = 1;
float SI = (P * T * R) / 100;
printf ( "Simple Interest = %f\n" , SI);
return 0;
}
|
Java
import java.io.*;
class GFG
{
public static void main(String args[])
{
float P = 1 , R = 1 , T = 1 ;
float SI = (P * T * R) / 100 ;
System.out.println( "Simple interest = " + SI);
}
}
|
Python3
P = 1
R = 1
T = 1
SI = (P * R * T) / 100
print ( "simple interest is" , SI)
|
C#
using System;
class GFG {
public static void Main()
{
float P = 1, R = 1, T = 1;
float SI = (P * T * R) / 100;
Console.Write( "Simple interest = " + SI);
}
}
|
PHP
<?php
$P = 1;
$R = 1;
$T = 1;
$SI = ( $P * $T * $R ) / 100;
echo "Simple Interest = " . $SI ;
?>
|
Javascript
<script>
let P = 1, R = 1, T = 1;
let SI = (P * T * R) / 100;
document.write( "Simple Interest = " + SI);
</script>
|
Output :
Simple Interest : 0.01
Time complexity : O(1)
Auxiliary Space : O(1)
Last Updated :
21 Feb, 2024
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...