Question: Implement the following code using variable of type pointer to one-dimensional array. #include #include using namespace std; void getSentence(char sentence[]); void Reverse(char sentence[], char reverse[]);

Implement the following code using variable of type pointer to one-dimensional array.

#include

#include

using namespace std;

void getSentence(char sentence[]);

void Reverse(char sentence[], char reverse[]);

void displayReverse(char sentence[], char reverse[]);

int main()

{

char sentence[100];

char reverse[100];

getSentence(sentence);

Reverse(sentence, reverse);

displayReverse(sentence, reverse);

return 0;

}

void getSentence(char sentence[])

{

cout << "Enter the sentence: ";

cin.getline(sentence, 100);

}

void Reverse(char sentence[], char reverse[])

{

int length = strlen(sentence);

int index = 0;

for (int i = length - 1; i >= 0; i--)

{

reverse[index] = sentence[i];

index++;

}

cout << "Reverse: " << reverse;

}

void displayReverse(char sentence[], char reverse[])

{

cout << " Original sentence: " << sentence;

cout << " Sentence in reverse: " << reverse;

}

1. Implement a function that asks the user for the sentence, the function must have a pointer type argument to an array of characters. 2. Implement a function that writes it in reverse order of the character array and stores them in another character array. The function must have two pointer type arguments to an array of characters. 3. Implement another function that prints the original arrangement and the arrangement in reverse order. The function must have two arguments, the pointer type towards an array of characters 4. Implement the pointer notation within the codes of both functions.

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!