type or paste code here
```bool isPalindrome(int N)
{
string str = "" + N;
int len = str.length();
for (int i = 0; i < len / 2; i++) {
if (str[i] != str[len - 1 - i])
return false;
}
return true;
}
why its working properly?
But When
bool isPalindrome(int N)
{
string str = "" + N;
cout<<str; // this line displaying error
}
return true;
}
why cout<<str displaing error?
You cannot assign int directly to string .
Instead of this
string str = "" + N;
use this
string str = to_string(N);
// here to_string STL converts int to string .You can read about to_string STL from google.