Question: Write a function mean, which follows the following specification: Input: a 0 , a 1 , a 2 , and a 3 contain ( signed

Write a function mean, which follows the following specification:
Input: a0, a1, a2, and a3 contain (signed) integers, with
Output: Return in a0 the arithmetic mean of the input values. If the mean is not an integer, round the number down.
Example: If a0 contains 1, a1 contains 2, a2 contains 3, and a3 contains 4, then the mean is
. Thus, the expected output is 2.
Example: If a0 contains -1, a1 contains -2, a2 contains -3, and a3 contains -4, then the mean is
. Thus, the expected output is -3.
Hint: RISC-V standard does not have a division instruction or a multiplication instruction. However, some other instruction can be used to divide by certain numbers. What instruction is that?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!