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

Solve Section 4 and 5 only Section 1: Using the MARS or SPIM simulator develop a

ID: 3792773 • Letter: S

Question

Solve Section 4 and 5 only

Section 1: Using the MARS or SPIM simulator develop a program that will evaluate the following expression 3 n n* (n 1) 15 where n is stored in a data location and is set to 15. Your program should use the system calls to print the result and to exit the program. Section 2: Using the MARS or SPIM simulator develop a program that will implement the following conditional statement. If n is even) n /2 else n 3 n 1; In this case, n is to be input by the user (assume they input a non-negative value), the conditional is performed, and the resulting n is to be output. Again, use the system calls for input, output, and exiting the program Hint: There is a remainder pseudoinstruction for the MIPS architecture that you can use to determine if the value is even or odd or you can look at bit o to determine if the value is even or odd.

Explanation / Answer

public class foo {

public static void main(String args[]) {
name();
colour();
favorite sportsShit();
}

public void echoShit() {
System.out.println("you are name");
System.out.println("your favorite colour");

System.out.println("your favorite sports team");
}

}

section5 :

  

void main () {

        int value = 2, list[2] = {$a0,$a1};

        swap (value, list[$a0]);

        swap (list[0], list[$a1]);

        swap (value, list[value]);

     }

     void swap (int $a0, int $a1) {

        int temp;

        temp = $a0;

        $a0 = $a1;

      $a1= temp;

}

   a.         Passed by value

                        With pass by value, none of the actual arguments are changed, so the variables retain the values they were initialized with.

            b.         Passed by reference

                        With pass by reference, the arguments are changed. After the first call to swap, value == 1 and list[0] == 2. After the second call to swap, list[0] == 3 and list[1] == 2. After the third call, value == 2 and list[1] == 1.

            c.         Passed by name

                        With pass by name, it’s as if the text of the arguments is inserted in the text of the subprogram. For the first two calls to swap, behavior is just like pass by reference. For the third call, swap acts as if it has the body

                                    temp = value;

                                    value = list[value];

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