Google Login
Questions
Unanswered
Tags
Users
Ask a Question
Welcome to the CSC Q&A, where you can get help (and share your knowledge) about computer science!
All categories
CSC 211
(749)
CSC 211 (F17)
(239)
CSC 211 (F16)
(185)
(Winter 15-16)
(184)
(Winter 14)
(140)
CSC 285
(360)
CSC 320
(1)
CSC 330
(0)
CSC 370
(0)
CSC 490
(123)
other
(9)
What would happen if you tried to calculate 2 % 10?
+3
votes
What happens when you try to calculate the remainder when the first number is smaller than the second? Would it result in a "no solution" or zero?
asked
Aug 30
in
CSC 211 (F17)
by
Lauren Endress
(
100
points)
Please
log in
or
register
to add a comment.
Please
log in
or
register
to answer this question.
1 Answer
+3
votes
Well modulus divides and provides the left over value. So you would divide 2 / 10 which would equal 0 (not very relevant) then the left over number is 2. So 2 % 10 = 2
Here some other examples:
5 % 2 = 1
4 % 3 = 1
104 % 20 = 4
101 % 102 = 101
answered
Aug 30
by
Daniel Zwiener
(
100
points)
Yes. As Daniel (from 285) says, 10 "goes into 2" ZERO whole times, with two left over. As a side note, you can also satisfy your curiosity by opening up Eclipse and actually *trying* it. It's good practice using Eclipse, and you'll find out the answer for sure! System.out.println(2 % 10); // typed inside some class's main method
Please
log in
or
register
to add a comment.
...