-2
#include <stdio.h>

int main()
{
    int x=5;  //x = interest rate(5%)
    int y=10000; //y = principal

    int n = 0;   //n = after years
    while (1)
    {
        n++;
        y += y*(x/100);
        if(y == 20000)
            break;

    }

    printf("%d years later, double.",n);

    return 0;
}

When I run it, nothing happens.

Description Resource Path Location Type cannot open output file mm.exe: Permission denied mm C/C++ Problem

I would appreciate it if you let me know what went wrong.

jinj
  • 9
  • 1

1 Answers1

0

Since you have X as an integer and it's value is 5, at

y+= y*(x/100)

Is equivalent to

y+= 0

as (5/100) with integer division yields 0. This results in while(1) looping infinitely, and thus will never allow the program to terminate.

Additionally, the permission denied error looks like it can be fixed by changing your save file location. Here is my source and some extra info

Hope this helps!