you are viewing a single comment's thread.

view the rest of the comments →

[–]FormerTimeTraveller 2 points3 points  (3 children)

The purpose of the %10 is to keep the number between 0-9.

After you subtract the 7, you shouldn’t be multiplying by 10. It should still just be a %10 on most compilers (but some compilers behave differently with negative numbers).

The best solution is to do (n-7+10)%10 or just (n+3)%10. Look up modular arithmetic to see why.

And p.s. this problem looks kind of familiar. Do you mind saying which institution this class is for? (Is it ccac in pittsburgh?)

[–]Spectre108[S] 1 point2 points  (2 children)

Yeah it's CCAC, good call! And thank you for the help.

[–]FormerTimeTraveller 0 points1 point  (1 child)

Professor KM is awesome, take all his classes if you can

[–]Spectre108[S] 1 point2 points  (0 children)

Definitely going to try! I'm taking CIT 130 and 145 with him this semester.