I am trying to solve a interest problem. Why is this code Giving Runtime error? I Cannot figure out any reason. Is it because of the use of float?
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char** argv) {
float c,temp,temp2,x;
float r;
int n,ans;
scanf("%f",&c);
if(c>0 )
{
scanf("%d",&n);
if(n>0)
{
scanf("%f",&r);
if(r>=0)
{
temp=n;
temp2=c;
while(temp>0)
{
x=c*1200/(1200+r);
c=temp2+x;
temp--;
}
ans=(int)x;
printf("%d\n",ans);
}
}
}
return 1;
}