Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

/*1. Design and write a program that will accept a sentence as input, reverse the words and print the sentence out backwards. Ex: The movie

/*1. Design and write a program that will accept a sentence as input, reverse the words and print the sentence out backwards. Ex: The movie was not very true to the book. Output: book the to true very not was movie The (NOTE: You may keep the period after book if you want to.)*/

#include "stdafx.h" #include #include #include

using namespace std;

int main(void) { string sentence; string ecnetnes; string part = ""; char letter; int length = 0, position = 0, i = 0;

cout << "Enter sentence:" << endl; getline(cin, sentence);

position = sentence.length() - 1; // Set position to last character.

while (position >= 0) { letter = sentence.at(position); ecnetnes = ecnetnes + letter; // Concatenate a letter position--; }

cout << "The reversed sentence is. " << endl << ecnetnes << endl;

system("pause"); return 0; }

So my sentence is printing out back wards but it should keep the word orientation the same as before?

Please advise

Thanks

The instructions are up top

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions

Question

Different types of Grading?

Answered: 1 week ago

Question

Explain the functions of financial management.

Answered: 1 week ago

Question

HOW MANY TOTAL WORLD WAR?

Answered: 1 week ago

Question

Discuss the scope of financial management.

Answered: 1 week ago