The following questions are asked in the lecture about C language at the university.
"The loan is 30 million yen, and the annual interest rate is 2%. If I want to repay each 2 million yen from one year after the loan, calculate the number of years until the loan is paid off, and create a program to display in C language. Submit the file that saved the program."

I made it while looking at the reference book, but [30 million yen, 2%, 2 million yen from one year later]
I am suffering from not knowing where to put the keyword.

The software used for creation is VS code, OS is Win10 32bit.

Can anyone give me some tips or examples for creating this program?
I would appreciate your help.
I kindly thank you.

    int n;
    long x,y,z,s;
    float r;
    printf("borrow, repayment, enter annual interest ==>");
    scanf("%ld %ld %f",&x,&y,&r);
    n = 0;
    s = 0;
    z = x;
        z = z*(1+r/100);/*n loan balance */
        if (z<=y) break;/* If the balance of the loan is less than or equal to the repayment amount, exit the loop */
        z-=y;/*n Borrowing balance after repayment in fiscal year */
        s+=y;/* Accumulate repayment amount */
        printf("FY=%d Repayment=%8ld Balance=%8ld Repayment=%8ld\n",n,y,z,s);
    s+=z;/* Add final repayment amount */
    printf("FY=%d Last Repayment=%8ld Total Repayment=%10ld\n",n,z,s);
    return (0);
  • Answer # 1

    An error occurred during compilation in the program I created, but I'll fix it.
    Thank you to everyone for your advice.

Related articles