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

#include <iostream> using namespace std; int overtake(int a, int b){ // Moved th

ID: 3547223 • Letter: #

Question

#include <iostream>
                                    using namespace std;

                                    int overtake(int a, int b){ // Moved the do..while loop into a typed function
                                    do{ // with pass by value parameters.
                                    a += 25;
                                    b += 20;
                                    }
                                    while (a < b);
                                    return a;
                                    }

                                    int main() {
                                    int cop = 0;
                                    int driver = 40;
                                    cout << overtake(cop, driver);
                                    return 0;
                                    }

Explanation / Answer

main:

add $t1,$t1,0 #$t1-cop

add $t2,$t2,40 #$t2-driver

j overtake

overtake:

do:

add $t1,$t1,25

add $t2,$t2,20

blt $t1,$t2,do

mov $a0,$t1

li $v0, 1

syscall

li $v0, 10

syscall