Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Linked Data A Geographic Perspective

Authors: Glen Hart, Catherine Dolbear

1st Edition

1000218910, 9781000218916

More Books

Students also viewed these Databases questions