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

Section 1: Using the MARS or SPIM simulator develop a program that will evaluate

ID: 3792914 • Letter: S

Question

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

Section 4:

#include<iostream>

#include<stdio.h>

#include<stdlib.h>

using namespace std;

void main()

{

SubFunc("asha", "black", "IndianCricket");

system.exit();

}

void SubFunc(string name, string color, string sports)

{

cout<<"My name is ";

cout<<name<<endl;

cout<<"My favourite color is ";

cout<<color<<endl;

cout<<"My favourite sports team is ";

cout<<sports<<endl;

}

Section 5:

#include<stdio.h>

#include<stdlib.h>

using namespace std;

int main()

{

int num1, num2, num3;

cout<<"enter two numbers:";

cin>>num1>>num2;

num3 = gcd(num1, num2);

if(gcd)

cout<<"GCD is "<<num3<<endl;

else

cout<<"invalid input"<<endl';

return 0;

}

int gcd(int a, int b)

{

return (b != 0) ? gcd(b, a%b) : a ;

}

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