Simple interest program in c is a simple program to calculate simple interest.
In this tutorial we are going to see the concept of simple interest, what is simple interest, how it is calculate simple interest, simple interest formula and c program to find simple interest.
Simple interest and find compound interest in are important and similar topic.
Let’s start with introduction to simple interest
What is Simple Interest?
Lets see meaning of Simple interest : Simple interest is the method of finding the interest charges on loan. Simple interest is determined by multiplying interest rate, principal and and number of days.
Simple Interest formula :
To find simple interest we use a simple formula
Simple interest = (rate * principal * no of days)/100
Where principal is principal amount to be invested
Rate is interest rate in percentage
And no of days is time period for investment.
Principal = 1200
Rate = 4.6
Time = 2
Simple interest = (1200 * 4.6 * 2)/100
Simple interest = 110.4
Logic to implement simple interest program in c :
We take a user input principal, rate and time. The using formula we calculate simple interest. And print simple interest.
Concept you need to know from c programming
2. Variables and datatype in c
3. Input and output in c
Algorithm to find simple interest in c
2. Declare variable
3. Take input principal, rate and time from user
4. Using formula calculate simple interest
4. Print simple interest
C program to find simple interest
printf("Enter Rate in percentage \n");
printf("Enter Time in years(decimals)\n");
printf("Simple Interest is %f\n",simpleInterest);
1. Include header file
2. Write a main function
3. Declare variables
p => to store principal amount
r => to store rate of interesr
t => to store no of time for investment
simpleInterest => to store calculated simple interest
4. Take a input principal, rate and time from user
Suppose for example :-
p = 1200
r = 4.6
t = 2
5. Now calculate simple interest by using formula
simpleInterest =(float) (p * r * t) / 100
If we want result in float value then we require to type cast the result to float. We done externally by specifying float after assignment so that after calculating the value is type casted to floating point value and then assigned to simpleInterest.
simpleInterest = ( 1200 * 4.5 * 2) /100
simpleInterest = 110.4
6. Next print calculated simple interest.