0
Can anyone provide me the code to find simple interest in c?
5 odpowiedzi
0
Have you tried it yourself yet? Please try to create the program, and then we can help you. You need to take three inputs in, and convert those to a integer. You can basically use scanf() to do that. Once you have that, you need to plug a couple of numbers into the equation:
int final_result = principal * (1 + (rate * time)) /*principal, rate, and time are the three inputs*/
You can finally output this to the console.
+ 1
What's the problem in making one on your own??
+ 1
Okay, you have a couple of errors in your code. I don't normally program in C, but the first mistake I see is that you didn't provide the return type for main(), which is int. So:
int main() /*This tells the program the return value*/
Next, another error is that you didn't put & before converting the input to a float. So, for each input, you need to do something similar to this:
scanf("%f", &p); /*converts input to float, and gives that value to p*/
Lastly, don't put parentheses around the return value:
return 0; /*this should do*/
0
#include <stdio.h>
main()
{
float p,r,t,i;
printf ("enter the no. of year");
scanf("%f",t);
printf ("enter the principal amount");
scanf("%f",p);
printf ("enter the rate of interest");
scanf("%f",r);
i=(p*r*t)/100;
printf("the total interest %f",i);
return(0);
}
Can u help to find the error over here
0
#include <stdio.h>
main()
{
float p,r,t,i;
printf ("enter the no. of year");
scanf("%f",t);
printf ("enter the principal amount");
scanf("%f",p);
printf ("enter the rate of interest");
scanf("%f",r);
i=(p*r*t)/100;
printf("the total interest %f",i);
return(0);
}
https://www.sololearn.com/discuss/2162622/?ref=app