Question: // Convert the following code into MIPS #include #include using namespace std; //method to reverse the string char *Reverse(char *s) { int len=strlen(s);//finding length of

//Convert the following code into MIPS

#include

#include

using namespace std;

//method to reverse the string

char *Reverse(char *s)

{

int len=strlen(s);//finding length of the string

char *front=s;//0th index

char *rear=(s+(len-1));//last index

//condition where front less than rear

while(front

{

//swaping

char t=*front;

*front=*rear;

*rear=t;

//incrementing front

front++;

//decrementing rear

rear--;

}

//returning reversed string

return s;

}

//main method

int main()

{

//Allocating memory for the string

char *s=new char[sizeof(char)*100];

//prompting user to enter string

cout<<" Enter a string: ";

cin>>s;

//passing string to Reverse method

s=Reverse(s);

//displaying string after reversing

cout<<" After reversing: ";

cout<

//deleting memory allocated

delete [] s;

s=NULL;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!