0
Output string backward
How to output string variables backwards
7 odpowiedzi
+ 3
show your attempts first
+ 1
#include <iostream>
#include <string>
using namespace std;
int main () {
string word;
cout << "Enter the word you want it to be written backwards" ;
cin >> word;
// this is where i stopped
return 0;
}
+ 1
Hakam This can't be your efforts. Any new learner can do this.
+ 1
string speakBackwards(string str) {
string s = "";
int counter = 0;
for (int i = static_cast<int>(str.size()) - 1; i >= 0; i--) {
s += str[i];
str += s[counter++];
}
return s;
}
Usage:
word = speakBackwards(word);
0
Your attempt?
0
Believe it or not, this is the attempt!. I saw someone's comment that she made a program to print string backwards, and that's what i am trying to discover.