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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started