0

In order to pritnt egabrag is there any wrong

#include <iostream> using namespace std; int main() { String a = "garbage"; String rev=" egabrag"; cin>>a; rev a="egabrag"; cout<<rev<<endl; return 0; }

3rd Jun 2020, 8:18 AM
The Black Hat 🇨🇦🇧🇩
The Black Hat  🇨🇦🇧🇩 - avatar
2 Réponses
0
There are some mistakes here: The type string needs to be written in lowercase string a = "garbage; (same for rev) What should the line rev a = "egabrag"; do? Before the = only one variable is allowed.
3rd Jun 2020, 8:30 AM
Michi
Michi - avatar
0
To print the string reverse use loop from (end --> begining) #include <iostream> using namespace std; int main() { string a = "garbage"; for(int i=a.length()-1; i>=0; i--) cout<<a[i]; return 0; }
3rd Jun 2020, 9:10 AM
Robin Singh
Robin Singh - avatar