I just started learning C programming. My book has this piece of code:
main () { int p, n; float r, si; p = 1000; n = 3; r = 8.5; si= p*n*r/100; printf("%f", si); }
The output I received was "255.000000"
I, although I will modify it using the scanf function, so I wrote the following:
main () { int p, n; float r, si; printf("Enter value for p: \n"); scanf("%d", &p); printf("Enter value for n: \n\n"); scanf("%d", &n); printf("Enter valuse for r: \n\n"); scanf("%d", &r); si= p*n*r/100; printf("\nYour Simple Interest is %f\n\n", si); }
No matter what values ββI give p, n, r, I always get 0.000000 ..
I also tried to give values, p = 1000, n = 3, r = 8.5, but still I get 0.000000 ..
source share