i need to keep subtracting 24 recursively and stop only when the subtraction would give a negative result
this is what i am doing
do
{
current_val = current_val - 24;
} while (current_val > 0);
so if the current value is 77 then it should subtract (24) 3 times and return 5
but its gets stuck in the while loop :(
am i doing something wrong here? any guidance would be greatly appreaciated
int current_val;
int count = 0;
cin>>current_val;
if(current_val>24)
{
do{
count++; // divide count
current_val -= 24;
}while(current_val>24); // before was >0 which would return a neg number if > 24
cout<<"Remainder = "<<current_val<<endl
<<"Divided "<<count<<" times"<<endl;
}
else
cout<<"NOT DIVISABLE"<<endl; // if less than 24