C++ program to find the simple interest please answer
Answers
Answer:
# include<iostream>
using namespace std;
// function declaration
double calculateInterest(double p, double t, double r);
// main function
int main()
{
// declare variables
double p, t, r, interest;
// take input from end-user
cout << "Enter principal amount, time and rate:";
cin >> p >> t >> r;
// calculate interest
interest = calculateInterest(p, t, r);
// display result
cout << "Interest = " << interest << endl;
return 0;
}
// function to calculate interest value
double calculateInterest(double p, double t, double r)
{
return (p*t*r)/100;
}
Answer :
Required C++ Program :
To Find Simple Interest ;
#include <iostream>
using namespace std;
int main ( )
{
float p_Amount , n_Year , i_Rate ,
int_Amount ;
cout <<"Enter the Principal Amt. in
Rupees: " ;
cin>> p_Amount ;
cout<<"Enter the no.of Years of
Deposit : " ;
cin>>n_Year ;
Cout<<"Enter the rate of interest in
Percentage : " ;
cin>> i_Rate ;
int_Amount = p_Amount * n_Year *
i_Rate / 100 ;
cout <<"Simple Interest for the
Principal Amt. "
<<p_Amount
<<"Rupees for a period
of"<<n_Year
<<"Years at the rate of
Interest"<<i_Rate
<<"is " <<int_Amount <<"
Rupees" ;
return 0;
}
Output :
•Enter the Principal Amt in Rupees : 100
•Enter the no.of years of Deposit : 2
•Enter the rate of interest in Percentage: 10
•Simple Interest for the Principal Amt 100 Rupees for a period of 2 Years at the rate of interest 10 is 20 Rupees.
Look the Attachment ; for an easy way to find Simple Interest.