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

Please Download “MARIE and Datapath Simulators” package from the following link:

ID: 3861531 • Letter: P

Question

Please Download “MARIE and Datapath Simulators” package from the following link: http://computerscience.jbpub.com/ecoa/3e/simulators.aspx In the package, there are four examples provided. Use the simulator to write the MARIE assembly code and show the running results. In the submission, please provide both source code

(1) Find the seventh value of the Fibonacci number sequence. The following formula describes the sequence: Fib(1) = 1, Fib(2) = 1, Fib(n) = Fib(n-1) + Fib(n-2). The program calculates Fib(7).

(2) Create a subroutine to implement the following statement in C language: int num = condition ? First number : Second number That is, if “condition” is 0, “num” gets the value of “Second number”; otherwise, it gets the value of “First number”. Consider two cases: a) condition = 1; b) condition = 0. Assume “First number” is 10, and “Second number” is 20.

Explanation / Answer

1. To find the seventh value of the Fibonacci Series:

Begin

Loop

Finish

FinishEven

Tracing through for n = 7:

So the Fib(7) is 13

2. statement in C

#include<stdio.h>

int main()

{

int num,fn,sn,con;

printf("Enter the First Number : ");

scanf("%d",&fn);

printf(" Enter the Second Number : ");

scanf("%d",&sn);

printf(" Enter the Condition either 1 or 0 : ");

scanf("%d",&con);

num = ((con==0)?sn:fn);

printf(" For Condition = %d, num gets the value = %d ",con,num);

}