1#include <iostream>
2#include<string>
3#include<algorithm>
4using namespace std;
5int main()
6{
7string str;
8 getline(cin,str);
9 reverse(str.begin(),str.end());
10 cout<<str;
11}
1#include <iostream>
2using namespace std;
3
4int main() {
5
6 string greeting = "Hello";
7 int len = greeting.length();
8 int n=len-1;
9 for(int i=0;i<(len/2);i++){
10 //Using the swap method to switch values at each index
11 swap(greeting[i],greeting[n]);
12 n = n-1;
13
14 }
15 cout<<greeting<<endl;
16}
1#include <iostream>
2//The library below must be included for the reverse function to work
3#include<bits/stdc++.h>
4using namespace std;
5
6int main() {
7
8 string greeting = "Hello";
9 //Note that it takes the iterators to the start and end of the string as arguments
10 reverse(greeting.begin(),greeting.end());
11 cout<<greeting<<endl;
12}