0

Can anyone provide me the code to find simple interest in c?

8th Feb 2020, 2:11 PM
Tutankhamun
5 ответов
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.
8th Feb 2020, 2:23 PM
Jianmin Chen
Jianmin Chen - avatar
+ 1
What's the problem in making one on your own??
8th Feb 2020, 2:21 PM
Arsenic
Arsenic - avatar
+ 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*/
8th Feb 2020, 2:38 PM
Jianmin Chen
Jianmin Chen - avatar
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
8th Feb 2020, 2:26 PM
Tutankhamun
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
8th Feb 2020, 2:27 PM
Tutankhamun