Reduce last week’s reverse_string.cpp to a module reverse.h and reverse. cpp. He
ID: 3620608 • Letter: R
Question
Reduce last week’s reverse_string.cpp to a module reverse.h and reverse.cpp. Here is reverse.h:
#pragma once
void reverse( char * );
Write, test and submit reverse.cpp. Use pointers in preference to array
logic wherever you can, and use the keyword const where it makes
sense to do so.
reverse_string.cpp:
#include <iostream>
using std::cout;
using std::endl;
using std::cin;
int main()
{int i,j,n;
char a[50],b[50];
cout<<"Enter a string: ";
cin>>a;
n=strlen(a);
for(i=0;i<n;i++)
*(b+i)=*(a+n-i-1);
*(b+i)='';
cout<<a<<" reversed is "<<b<<" ";
system("pause");
return 0;
}
Explanation / Answer
reverse_string.cpp: #include using std::cout; using std::endl; using std::cin; int main() {int i,j,n; char a[50],b[50]; couta; n=strlen(a); for(i=0;i *(b+i)=*(a+n-i-1); *(b+i)=''; coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.