Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Determine the following information about a value passed in as a parameter. (a)

ID: 3839145 • Letter: D

Question

Determine the following information about a value passed in as a parameter. (a) Is the value a multiple of 7, 11 or 13? (b) The sign of the value (-1 if it is negative, 0 if it is 0 and 1 if the value is positive). You should write a function with three type int parameters, one input parameter (the value) and two other output parameters. The function should send back the answers to the two questions above in the output parameters of the function. Some sample input data might be: 104 3773 13 121 77 30751.

Explanation / Answer

Here is code in c#:

// return divisible 1 if value is divided by 7, 11, 13 : (0 if not divisible)
// return sign -1 if it is negative, 0 if it is 0 and 1 if the value is positive
public static void multiple(int value, out int divisible,out int sign)
{
if ((value % 7 == 0) || (value % 11 == 0) || (value % 13 == 0))
{
divisible = 1; // if divisible
}
else
{
divisible = 0;
}
// check the sing
if (value < 0)
sign = -1; // negitive
else if (value > 0)
sign = 1; // positive
else
sign = 0; // zero
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote