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

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?

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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.