#include <iostream> using namespace std; bool isPalindrome(int x) { //complete the function } int main() { int n; cin >>n; if(isPalindrome(n)) { cout <<n<<" is a palindrome"; } else { cout << n<<" is NOT a palindrome"; } return 0; }
1/16/2021 8:54:01 AM
PARUCHURI YASWANTH12 Answers
New AnswerPARUCHURI YASWANTH Check this and compare with your code https://code.sololearn.com/cewmk9Y1QUql/?ref=app
PARUCHURI YASWANTH And don't make different thread for same question. https://www.sololearn.com/Discuss/2667495/?ref=app
PARUCHURI YASWANTH I told you method should return true if original and reverse values are equal so where is this part in your code?
PARUCHURI YASWANTH And check if original input and reverse input are equal then return true.
do { digit = num % 10; rev = (rev * 10) + digit; num = num / 10; } while (num != 0);
#include <iostream> using namespace std; bool isPalindrome(int x) { //complete the function int n,s=0,r; x=n; while(n!=0) { r=n%10; s=s*10+r; n=n/10; } } int main() { int n; cin >>n; if(isPalindrome(n)) { cout <<n<<" is a palindrome"; } else { cout << n<<" is NOT a palindrome"; } return 0; }
SoloLearn Inc.
4 Embarcadero Center, Suite 1455Send us a message