int main() int arr[] = {5,2,1,4,6,3}; cout<

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter3: Understanding Structure
Section: Chapter Questions
Problem 7RQ
icon
Related questions
Topic Video
Question

Can someone please help me translate this to MIPS code and also screenshot compiled code on MIPS STIMULATOR. Much appreciate if you keep it short and simple. Thanks

#include <iostream>
using namespace std;
int lookup(int arr[], int num, int cnt){
for(int i = 0;i<cnt;i++){
if(arr[i]==num){
return i;
}
}
return -1;
}
int main()
int arr[] = {5,2,1,4,6,3};
cout<<lookup(arr,5,3)<«endl;
cout<<lookup(arr,1,3)<«endl;
cout<<lookup(arr,7,6)<«endl;
cout<<lookup(arr,4,3)<<endl;
return 0;
Transcribed Image Text:#include <iostream> using namespace std; int lookup(int arr[], int num, int cnt){ for(int i = 0;i<cnt;i++){ if(arr[i]==num){ return i; } } return -1; } int main() int arr[] = {5,2,1,4,6,3}; cout<<lookup(arr,5,3)<«endl; cout<<lookup(arr,1,3)<«endl; cout<<lookup(arr,7,6)<«endl; cout<<lookup(arr,4,3)<<endl; return 0;
Expert Solution
steps

Step by step

Solved in 4 steps

Blurred answer
Knowledge Booster
Instruction Format
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
New Perspectives on HTML5, CSS3, and JavaScript
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:
9781305503922
Author:
Patrick M. Carey
Publisher:
Cengage Learning