Reputation: 39
I have set the correct directory paths for Turbo C. But yet it gives the output as 0.000000
Following is the program:
#include <conio.h>
#include <math.h>
#include <stdio.h>
void main() {
int n;
float r, si, ci, p;
clrscr();
printf("enter principle amount\n");
scanf("%f", &p);
printf("enter rate of interest\n");
scanf("%d", &r);
printf("enter number of years\n");
scanf("%f", &n);
si = p * n * r / 100;
ci = p * (pow((1 + (r / 100)), n) - 1);
printf("simple interest=%f\n", si);
printf("compound interest=%f", ci);
getch();
}
It is supposed to give numbers instead of 0.000000
Any help?
Upvotes: 2
Views: 340
Reputation: 73384
Change:
scanf("%f",&n);
to:
scanf("%d",&n);
since n
is an integer, not a float, as suggested in the comments already.
For r
, which is of type float
, you should use scanf("%f",&r);
.
PS: Consider using a modern compiler, such as GCC.
Upvotes: 1