Microsoft
98-382 · Question #31
You are writing a function that calculates the remainder for integer division. The function receives two parameters, a and b, and must return the remainder that is left over when the integer a is…
The correct answer is E. 02 a = a % b; 03 return a. See the full explanation below for the reasoning.
Question
You are writing a function that calculates the remainder for integer division. The function receives two parameters, a and b, and must return the remainder that is left over when the integer a is divided by the integer b.
You create the following code. Line numbers are included for reference only.
01 function remainder(a, b) {
02
03
04 }
You want to complete the function for lines 02 and 03.
Which two sets of code segments should you use? Each correct answer presents a complete solution. (Choose two.)
Options
- A02 a = a / b - a; 03 return a;
- B02 b = b % a; 03 return b;
- C02 b %-= a; 03 return b;
- D02 a %= b; 03 return a;
- E02 a = a % b; 03 return a;
- F02 b = b / a - b; 03 return b;
How the community answered
(41 responses)- A5% (2)
- B7% (3)
- C2% (1)
- D15% (6)
- E71% (29)
Community Discussion
No community discussion yet for this question.