0
Program to print simple intrest
Please ans
8 ответов
+ 1
Whats your idea for the program?
Ok, so lets step it out in pseudo code then build it. What C do you know so far?
+ 1
Actually i am a beginner
0
Want to know
0
Lets start with what is the definition of simple interest.
We will go with
Simple Interest (SI) = (Principle * Interest * Time) / 100
Far enough?
0
Just going with that we could set three variables but we need to know what types
Principle and Interest are money so they have a decimal we can use float
float principle = 45000.50; //$45,000.50
float interest = 3.5; //This is 3.5%
next is time since we are talking simple interest we will look at number of years so we will use an integer
int time = 3 //3 years
now we can use some simple math but we have to set a variable to return it for us we know it will be money again so we will use a float.
float simpleInterest = (principle * interest * time) / 100;
the variable simpleInterest would now hold the value of the Simple Interest
We could use a print function to display it or return it to some other function.
printf("The simple interest of $45,000.50 at 3.5% for 3 years is: %.2f\n", simpleInterest);
How would you put all that together?
0
Oh thank you so much william❤️
0
#include<studio.h>
Void main()
{
Float interest, principle;
Int time;
Printf("simple interest is %d", (principle*time*interest)/100);
}
0
Vinuthna Reddy Good attempt a few issues, C is case sensitive your functions won't work, main has to return something can't be void. The argents list can be void though.