I am new to C programming, so this question might sound foolish. I have a problem with output of a program (sometimes the output is wrong)
Following is the program: (I am using Turbo C compiler)
/* Calculate simple interest */
int p, n;
float r, si;
printf("Enter values of p, n, and r");
scanf("%d, %d, %f", &d, &d, &f);
printf("Simple interest=%f", si);
There is no error in this program. Output is also right but only for small integers.
e.g. If I enter p=1000, n=5, r=10, answer is RIGHT.
BUT for p=10000, n=5, r=10, answer is wrong (in minus value and totally wrong)
I think this is because of integer value limitations.
If yes, what is the solution to it so that I can use a bigger number.
If no, what is the reason for the error?
Please help me.
Thank you very much.