C++ Program To Reverse a Sentence or String

Problem:- Write A C++ Program To Print Reverse Sentence or reverse a string in c++ program or how to reverse a string in c++ using functions or reverse a string in c++ using for loops or reverse string in c++ without using a function or how to reverse a string in c++ using strrev or Reversing a string in c using a while loop or C++ Program to Reverse a String or C program to reverse a given number using do..while loop or c++ program to reverse a string using for loop or C++ Program To Reverse a Sentence or String.

Check This:- Hacker rank solution for Strings, Classes, STL, Inheritance in C++.

Logic:- Like reverse string, this is a reverse sentence. So first we are taking an input from the user after that we are finding the string or sentence last index point so we can reverse a sentence while reversing a sentence if any space occurs we take and space and print space after that again string starts printing. I  strongly prefer a program first try to understand this program so can understand the logic basically what is going on. Check C Program For Reverse A String Without (srtrev) Using Library Function. Now try by yourself if you are getting problem Comment Below and also sure that you have read the full post.

Also Check:- Geeksforgeeks solution for School, Basic, Easy, Medium, Hard in C++.

Extreme Recommended:- Like our Facebook Page or Join our Facebook Group and Google plus Community for up-to-date for a new post or if you have any Query you can ask there with lots of coders also suggest to your Friends to join and like our page.


using namespace std;
int main()

/*Visit - www.programmingwithbasics.com*/
    cout<<"\nVisit - www.programmingwithbasics.com";
  int i, prev, next, j, k;
  char st[100];

  cout<<"\n\nEnter The Sentence: ";


  cout<<"\n\nSentence In Reverse Order Is As Follow \n\n";
    if(st[k]==' '||k==0)
cout<<" ";

  return 0;


No comments:

Post a Comment