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

Write a program reverse_string.cpp, using pointers to the characters involved, t

ID: 3620427 • Letter: W

Question

Write a program reverse_string.cpp, using pointers to the characters
involved, to reverse the string “Blacksburg” as “grubskcalB” and to
print the result to std::cout. Internally, your program should store the
original string in a char[] and the reversed string in another char[],
but it should use pointers rather than the [square-bracket] notation to
access the array elements. Let your reversed array have length == 50.
(Don’t forget that, for cout to print it correctly, the reversed string
wants a null at the end.)

Explanation / Answer

please rate - thanks #include <iostream>
using namespace std;
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;
}



Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote