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

Write an m-file function that will take a scalar input, Input, and return two sc

ID: 2320805 • Letter: W

Question

Write an m-file function that will take a scalar input, Input, and return two scalars, Output1 and Output2, based on the following rules:

If Input is even, then Output1 is 0Otherwise:

If Input is negative, then Output1 is -1

If Input is greater than 10 but less than or equal to 100, Output1 is +1

Otherwise, Output1 is +2

Output2 has an initial value of Output1*Input

If Output2 is negative or odd, Output2 is Input.

** Hint: the built in function mod() execute a modular division and can return the integer remainder of a division problem.

Explanation / Answer

inp = input('Input the value:');

if(inp%2 == 0)

output1 = 0;

else if(inp < 0)

output1 = -1;

if(inp > 10 && inp <= 100)

output1 = 1;

else

output1 = 2;

output2 = output1*inp;

if(output2 < 0 || output2%2 == 1)

output2 = inp;

display(output2);

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