QUESTION IMAGE
Question
12 (03.02 lc)
a programmer is writing a program using ap exam pseudocode to calculate the modulus of two numbers. the programmer has written the following procedure.
procedure findmod(a, b)
{
mod ← a mod b
return mod
}
firstnumber ← 10
secondnumber ← 2
which of the following is the correct way to call the procedure to find the modulus of two numbers? (5 points)
○ modulus ← findmod(a mod b)
○ modulus ← procedure findmod(10, 2)
○ modulus ← findmod(a, b)
○ modulus ← findmod(firstnumber, secondnumber)
Brief Explanations
- The procedure
findMod(a, b)takes two input parametersaandbto compute their modulus. - The variables
firstNumber(set to 10) andsecondNumber(set to 2) hold the values we want to compute the modulus of. - A valid procedure call must pass the two values as arguments matching the procedure's parameter structure, without redefining the procedure or using invalid syntax in the call. The correct call passes the pre-defined variables to the procedure and assigns the result to
modulus.
Snap & solve any problem in the app
Get step-by-step solutions on Sovi AI
Photo-based solutions with guided steps
Explore more problems and detailed explanations
modulus ← findMod(firstNumber, secondNumber)