➤ Hello World! in C++
➤ Print Number in C++
➤ Add 2 Numbers C++
➤ Arithmetic Operation
➤ Sum Avg of 3 Number
➤ Area Program in C++
➤ Simple Interest in C++
➤ Find ASCII value in C++
➤ Swap 2 Number in C++
Flow Control Programs
➤ Even-Odd in C++
➤ +ve, -ve, 0 in C++
➤ Vowel-Consonant
➤ Greatest of 3 no.
➤ Check Leap Year
➤ Calculator Program
➤ Reverse a Number
➤ Sum of Natural Number
➤ GCD of 2 Number
➤ LCM of 2 Number
➤ Find Power in C++
➤ Fibonacci Series in C++
➤ Palindrome Number
➤ Find Factorial in C++
➤ Factorial Using Recursion
➤ Prime Number in C++
➤ Prime Number b/w 1-N
Array
➤ Linear Search in C++
➤ Binary Search in C++
Others
➤ Introduction to C++
➤ Data Types in C++
➤ Range of Data Types
➤ Void main, main vs int main
In this post, we will write a C++ program to calculate simple interest. Simple interest is a quick and easy 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.
The formula for simple interest is given as,
Simple Interest = (principal amount × interest rate × time) / 100
#include<iostream>
using namespace std;
int main()
{
// declare variables
float p, t, r, interest;
// take input from end-user
cout << "Enter principal amount, time and rate:";
cin >> p >> t >> r;
// calculate interest
interest = (p*t*r)/100;
// display result
cout << "Interest = " << interest << endl;
return 0;
}
Output:-
Enter principal amount, time and rate: 1000 10.5 11.9
Interest = 1249.5
Simple interest is calculated as ( principal amount * time * rate ) / 100. So, we need four variables that will store the value of the principal amount, time, rate, and interest. In this C++ program to calculate simple interest, We define four variables p, t, r, and interest which stores principal amount, time, rate, and interest respectively. Using the formula of simple interest, the value of interest is calculated.
Program to Find Simple Interest Using Function in C++
A function is a block of code that performs a specific task. Every program must have at least one function with the name main
. The execution of the program always starts from main function and ends with main function. Main function can call other functions to do some special task.
#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;
}
Output:-
Enter principal amount, time and rate:10000 5 9.9
Interest = 4950
If you enjoyed this post, share it with your friends. Do you want to share more information about the topic discussed above or do you find anything incorrect? Let us know in the comments. Thank you!
Follow Us
Instagram • Twitter • Youtube • Linkedin • Facebook • Pinterest • Telegram
Learn More C++ Programming Examples,
- Introduction to C++ Programming
- Data Types in C++ Programming
- Find Range of Data Types in C++
- Void main(), main() vs int main() in C++
- Hello World! Program in C++
- Addition of Two Numbers in C++
- Add Subtract Multiply Divide 2 Numbers
- Sum and Average of three numbers
- Area of Circle Triangle Rectangle in C++
- Calculate Simple Interest in C++
- C++ program to find ASCII value
- C++ program to swap two Number
- Check Even or Odd Number in C++
- Find Positive Negative Zero in C++
- Greatest of Three Numbers in C++
- Program to Check Leap Year in C++
- Simple Calculator Program in C++
- Program to Reverse a Number in C++
- Sum of Natural Numbers in C++
- C++ Program for GCD of Two Numbers
- C++ Program for LCM of Two Numbers
- Find Power of a Number in C++
- Fibonacci Series Program in C++
- Check Palindrome Number in C++
- Factorial of a Number Program in C++
- Factorial Using Recursion in C++
- Prime Number Program in C++
- Prime Number b/w 1 to N in C++
I was very pleased to find this great site. I need to thank you for your time due to this fantastic read!! I definitely savored every little bit of it and I also have you saved as a favorite to look at new stuff on your website.