How can I loop the following code add to the totalFrabjous_numbers

I am trying to find a way to add to the totalFrabjous_numbers if the numbers between a desired range are equal to my constant. I am only allowed to use (for,while,do) loops in the <iostream> library.


int totalFrabjous_numbers = 0;
for ( int inbetweenInteger = rangeMinimum;
inbetweenInteger <= rangeMaximum; ++inbetweenInteger )
{
if ( (inbetweenInteger % 10) == FRABJOUS_NUMBER)
{
totalFrabjous_numbers++;
}
if ( (inbetweenInteger /= 10) == FRABJOUS_NUMBER)
{
totalFrabjous_numbers++;
}
}
You have posted this before - perhaps you should clarify that thread first. It is frowned upon in this forum to double-post.

Last time you were asking for the sum of the "frabjous" numbers - now you are asking for the number of them. Make sure that your question is clear. (I had no idea what a "frabjous" number referred to until I read your previous thread).

You have also added new constraints as to what you should use. BTW, (for, while, do) loops have nothing to do with the <iostream> library.

From the way you have coded it you are picking off the decimal digits one by one by looking at remainders (the modulo (%) operation) and moving onto the next by integer division (the / or /= operation). Only the modulo operation will be checking whether a digit is a frabjous number; the integer divide operation (your second if block) effectively moves on to the next decimal digit to the left and you won't be incrementing your total there.

Rather than expecting people to do your homework for you (not fair on the rest of your class or, in the long term, on yourself), please post your whole code, not a fragment, and expect advice, not a full solution.
Indeed, I second @lastchance's comments.

OP: both @lastchance and I provided suggestions to your previous post on this topic, no reply from you and now you're back with this. I'm sorry to say but this is very poor behavior
thanks for the tips guys, as of now I am informed of this so called "poor behavior" and I thoroughly enjoyed being belittled. In the future I'll be more careful on double posting and providing adequate directions. @gunnerfunner @lastchance
Topic archived. No new replies allowed.