What is missing from this c program. please help me.... thanks?
View your credit file based on any of the UK credit reference agencies, or all three at once
LifeLock is the only Identity Theft Prevention Solution backed by a one-million dollar guarantee!Click here to get a 10% discount.
The simple interest on a loan is calculated by the formula
interest = principal * rate * days / 365;
The preceding formula assumes that rate is the annual interest rate, and therefore includes the division by 365 (days). Develop a program that will input principal, rate and days for several loans, and will calculate and display the simple interest for each loan, using the preceding formula.
#include<iostream.h>
#include <stdio.h>
int main(void)
{
int principal, rate, days, interest;
printf("enter principal\n");
scanf("%d", &principal);
printf(" enter rate\n");
scanf("%d", &rate);
printf(" enter days ");
scanf("%d", days);
interest = principal * rate * days / 365;
printf(" the interest is %d");
system("pause");
return 0;
}
What is missing from this c program. please help me.... thanks?No & in front of days in scanf
interest should probably not be integer in real life because of div by 365.
What is missing from this c program. please help me.... thanks?The corrected version.
#include <stdio.h>
int main(void)
{
double principal, rate, interest;
int days;
printf("enter principal $");
scanf("%lf", &principal);
printf(" enter rate :");
scanf("%lf", &rate);
printf(" enter days ");
scanf("%d", &days);
interest = principal * rate * days / 365.0;
printf(" the interest is %f", interest);
printf("Press Enter>");
fflush(stdin);
getchar();
return 0;
}
More Related Questions and Answers ...
The loan information post by website user , we not guarantee correctness.
