program must be in C++.
Write a program in c++, To print a reverse string of any character,the length of character should not exceed t
#include %26lt;string%26gt;
#include %26lt;iostream%26gt;
#include %26lt;algorithm%26gt;
using namespace std;
int main()
{
const string input_string("Can we reverse a string?");
string s(input_string.begin(), input_string.end());
// iterate through all of the characters
string::iterator pos;
for (pos = s.begin(); pos != s.end(); ++pos) {
cout %26lt;%26lt; *pos;
}
cout %26lt;%26lt; endl;
reverse (s.begin(), s.end());
cout %26lt;%26lt; "reverse: " %26lt;%26lt; s %26lt;%26lt; endl;
}
Reply:Can you plz elaborate ur question...
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment