RECENTLY PUBLISHED

6/recent/ticker-posts

Write a code snippet to reverse the contents of a given string without using strrev() function in C++.

 C++ PROGRAM





                                                                            Following is simple C++ Program that will reverse a string without using strrev() built-in string function.  We have just take one string as input from user and reverse that string with the help of for loop in C++ language. We hope you will really like this program.



C++ Code : -



#include<iostream>

using namespace std;

int main()

{

string str,s="";

cout<<"Enter a String:"<<endl;

getline(cin,str);

for(int i=0;i<str.length();i++)

{

s=str[i]+s;

}

cout<<endl<<"Reverse String is:"<<s;

return 0;

}




INPUT && OUTPUT:-








Post a Comment

0 Comments