Trying to change variable value, but it never changes

  arithmetic-expressions, c++, math

The value of the variable dc doesn’t change in my code. I’ve tried debugging it but it’s still never changing. I’m new to C++ coding.

What am I doing wrong, and how can I solve the problem?

From what I know:

  • It should change whenever I iterate because fd changes every time I complete a cycle, so It should work but it doesn’t.
  • There are like 6 variables and other conditions that affect dc.
#include<iostream>
#include<vector>
using namespace std;
#define ll long long


int main(){

    // int h,u,d,f;
    int h=6,u=3,d=1,f=10;

    // cin >> h >> u >> d >>f;

    while (h != 0)
    {
        int day=0, cl=0,dc=0, fd=0;

        while(true){

            dc= u - (f/ 100) * u * fd ;
            cout << dc << endl;

            if (dc > 0)
            {
                cl += dc - d;

                fd++;
                day++;

                if (cl > h)
                {
                    cout << "success on day " << day + 1;
                    break;
                }
                if (cl < 0)
                {
                    cout << "failure on day " << day + 1;
                    break;
                }

            }else{

                fd=0;
                cl -= d;
                day++;

                if (cl < h)
                {
                    cout << "failure on day " << day + 1;
                    break;
                }
            }
        }

        cin >> h >> u >> d >>f;
    }

    
    
    return 0;
}

Source: Windows Questions C++

LEAVE A COMMENT