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

Hello, I need help with an assignment: There is no user input for this program.

ID: 3852140 • Letter: H

Question

Hello, I need help with an assignment:

There is no user input for this program.

Create a char pointer. Initialize the pointer to point to "John Doe".

Print the name using the pointer.

Print the string in reverse order. That is print the last letter first, the second to the last letter next, and so on. You must use the char pointer for everything. You cannot use an index (subscript) anywhere in your program. That means you cannot have any [ ] in your program (no square brackets). Your code must work for any string not just "John Doe". Meaning if I change only your string from step 2 to "Samuel Smith", with no other modifications, your code should be able to print Samuel Smith backwards.

Print the string again as you did in step 3 (you will lose points for not printing the string again).

Do not use the CString class. Do not use the string class. Make sure all the code to reverse the string is your own original code. Do not use code or a routine authored by someone else even if that routine came with your C++ compiler. You can use the strlen function located in the cstring header file.

The final product should look like this

Explanation / Answer

the c++ programming code is

#include <iostream.h>

using namespace std;

void reversepointerdata(char*);


int main()
{
   //declaration of a pointer
char *data = "John Doe";

cout << "Name is: " << data << endl;
cout << "Name backwards is: ";
reversepointerdata(data);
cout << endl;


return 0;
}

//method that reverse the pointer data

void reversepointerdata(char *in)
{
int len = strlen(in);
for (int i= (len - 1); i > -1; i--)
{
char chr = *(in+i);
cout << chr;
}
}

the output is:Name is: John Doe
Name backwards is: eoD nhoJ

when we change the name of the pointer to Samuel Smith we get the output in reverse as htimS leumaS.

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