• 0

Might be simple for you java people


Question

I was presented with a problem in my class and I have yet to figure this out because the teacher didnt explain it well. What he wanted us to do is a take a set of numbers, we will say 12345 and then output them as 54321. He said we had to do this using the percentage sign "%". I am totally clueless as to how this works and how to set this up to do this. Can someone enlighten me on this % sign thingie and how it would be used to solve this problem?

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

% is the modulo operator. It essentially gives the reminder of a division.

12345%10 gives 5.

12345%10=5

12345/10=1234

1234%10=4

1234/10=123

123%10=3

123/10=12

Thats how u extract the digits.

Link to comment
Share on other sites

  • 0
% is the modulo operator. It essentially gives the reminder of a division.

12345%10 gives 5.

12345%10=5

12345/10=1234

1234%10=4

1234/10=123

123%10=3

123/10=12

Thats how u extract the digits.

hah, well noticed! i was reading the first post thinking 'wtf' :p

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.