-2

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;
}
Eugene Sh.
  • 16,386
  • 4
  • 33
  • 51

1 Answers1

0

Try return 0;

at the end...and it should work

Though ,I don`t know why returning more than 0 gives problem for online compiler.. It should work even with returning any int value.

  • Even for Netbeans `return 1` runs the problem without any problem. But on closing the output terminal , output window says **RUN FAILED (exit value 1, total time: 9s)** – Mandar Bhamare Aug 08 '15 at 19:22