Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

How can i continuously subtract the money until it gets negative in C langauge?

+3 votes
asked May 28, 2019 by Justine (150 points) 1 flag
#include <stdio.h>

int main()
{
    double mortgage;
    double payment;
    double balance;
    
    printf("Please enter a mortgage rate. \n");
    scanf ("%lf", &mortgage);
    printf("Please entert your payemnt \n");
    scanf ("%lf", &payment);
    printf("Remaining balance: %lf \n", mortgage-(mortgage*0.0285*1+payment));

    while(balance>1)
    {
        printf("Please entert your payemnt \n");
        scanf ("%lf", &payment);
        printf("Remaining balance: %lf \n", balance-(mortgage*0.0285*1+payment));
    }

    if (balance<0)
    printf("Remaining balance: %lf \n", balance-(mortgage*0.0285*1+payment));
    
    return 0;
}

1 Answer

0 votes
answered Aug 6, 2019 by Raghav7425 (320 points)

You have not declared any value for balance variable.

That's why your program gets terminated at line 13.

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...