0

Write a function which accepts a sentence as input parameter.
Each word in that sentence is to b reversed (remember: not the whole sentence to b reversed, each word should b reversed). Space should b there between each word.
Return the sentence with reversed words to main function and produce the required output
For ex:
Input:
Jack jill jung kill
Output:
kcaj llij gnuj llik

3
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by firstPerson
0

Have you had a sit down with a pen and paper and created a flow chart/pseudocode of what you can try?
What have you done so far?
How far are in are you, what kind of loops and are you familiar with? Are you using null terminated strings or string objects?

0

Something to add:
What you might want to look at it as is if: you are looping and you get to a white-space, write what you have stored in a second string backwards, then, start over again until you get to the next white-space, using what you have stored in that second string and writing it backwards, and again, and again, until you get to the end of the string. If a char array, this will continue until you reach \n.

There are many different ways you can do this, although my solution may not be 100% sound, it should get you very well into your planning process.

0

First figure out how to reverse one word, ex [hello] --> [olleh]. Then go on from there. There are many ways you can achieve this. Why don't you give it a try and come back if you have problem.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.