NEED HELP. very confused.

My teachers assignment sheet:
AN interesting number is a non negative integer that contains at least one digit having the value 7. A REALLY interesting number that that is Xth in the sequence of interesting numbers, where X is an interesting number. for example 1234 is not interesting because none of its digits are 7. 27 is interesting but not really interesting because it is the third interesting number, and 3 is not interesting. 79 IS REALLY interesting because it is the 17th interesting number(preceded by 7, 17, 27, 37, 47, 57, 67, 70, 71, 72, 73, 74, 75, 76, 77, and 78) and 17 is interesting

I just really don't know how to use the %mod. So if nobody could help me with the above question, then maybe you could just explain the mod to me. thanks guys.

cheers
So you are referring to the modulo operator, this is a tool that C++ has to divide two integers and return the remainder. Here is a good source to learn about this operator.

http://www.cplusplus.com/doc/tutorial/operators/

I am not sure what your question is, so try and narrow it down a little so we can help you as much as we can.
Dude, now i'm confused...
lol. Ok so basically, Lets say that I want the interesting numbers in 4's. The 4th interesting number would be 34. The 14th interesting number would be 49. The 24th interesting number would 140. the 34th interesting number would be 154.
So, both numbers must both have a 4 in it. I am currently dying over this right now.
What mod does is that it finds the remainder of a number divided by another number.

Let's say we have:

1
2
3
4
5
int x=5;
int y=3;
int lol = x%y;

cout << lol;


The output would be 2, since 3 goes into 5 only once, with a remainder of 2.

Now let's use a number, say 57, and see if it has a 7 in the ones place. We could write:

1
2
if (57%10 == 7)
     cout << "There is a seven in the ones place.";


Since 10 only fits into 57 five times, and has a remainder of 7, then there is a seven in the ones place.

If you want to find out if there is a 7 in the 10's place, we could write:
1
2
if (73/10 == 7)
     cout << "There is a seven in the 10's place.";


When you divide an integer by an integer, it essentially chops off the remainder. So 73/10 would give us 7.

I hope this helps!
JoshHenry, yes that helps so much! Thank you for the explanation as well as the examples. But now I have to figure out how to loop that with a "for" loop. Lets say I wanted a 3 to be the interesting number, How could i output every 3 (3, 13, 23, 30, 31, 32, 33, 34, 35...etc)?
Topic archived. No new replies allowed.