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; }
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.
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;
}