#include <stdio.h>
int main()
{
float principle;
float rate;
float year;
float si = (principle*rate*year)/100;
printf("what is the principal amount\n");
scanf("%f", &principle);
printf("what is the rate\n");
scanf("%f", &rate);
printf(" and for how many years\n");
scanf("%f", &year);
printf("Then si is %f", si);
return 0;
}
what is the principal amount
100
what is the rate
4
and for how many years
1
Then si is -0.000000
I am getting simple interest as 0.00000
not 4
why?
you need to calculate the simple interest after the principle, rate and year are populated
#include <stdio.h>
int main()
{
float principle;
float rate;
float year;
// float si = (principle*rate*year)/100; //wrong . you need to calculate after the principle, rate and year are populated
float si;
printf("what is the principal amount\n");
scanf("%f", &principle);
printf("what is the rate\n");
scanf("%f", &rate);
printf(" and for how many years\n");
scanf("%f", &year);
si = (principle*rate*year)/100;
printf("Then si is %f", si);
return 0;
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments