+ 1

Palindrome numbers

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

16th Jan 2021, 8:54 AM
PARUCHURI YASWANTH
PARUCHURI YASWANTH - avatar
14 Respostas
16th Jan 2021, 9:52 AM
A͢J
A͢J - avatar
+ 3
PARUCHURI YASWANTH I told you method should return true if original and reverse values are equal so where is this part in your code?
16th Jan 2021, 9:43 AM
A͢J
A͢J - avatar
+ 2
PARUCHURI YASWANTH Show your attempts.
16th Jan 2021, 8:58 AM
A͢J
A͢J - avatar
+ 2
PARUCHURI YASWANTH And don't make different thread for same question. https://www.sololearn.com/Discuss/2667495/?ref=app
16th Jan 2021, 9:00 AM
A͢J
A͢J - avatar
+ 2
PARUCHURI YASWANTH Share your complete code.
16th Jan 2021, 9:39 AM
A͢J
A͢J - avatar
+ 1
PARUCHURI YASWANTH And check if original input and reverse input are equal then return true.
16th Jan 2021, 9:07 AM
A͢J
A͢J - avatar
+ 1
Thank you so much sir It works 😊
16th Jan 2021, 9:58 AM
PARUCHURI YASWANTH
PARUCHURI YASWANTH - avatar
0
do { digit = num % 10; rev = (rev * 10) + digit; num = num / 10; } while (num != 0);
16th Jan 2021, 9:04 AM
PARUCHURI YASWANTH
PARUCHURI YASWANTH - avatar
0
#include <iostream> using namespace std; bool isPalindrome(int reverse, int check) { //complete the function bool status = true; if (reverse != check) { status = false; } return status; } int main() { int n, reverse = 0, rem; cin >> n; int check = n; while(n != 0){ rem = n % 10; reverse = reverse * 10 + rem; n /= 10; } if(isPalindrome(reverse, check) == 1) { cout << reverse <<" is a palindrome"; } else { cout << check <<" is NOT a palindrome"; } return 0; }
24th Sep 2021, 2:29 PM
Ben
Ben - avatar
22nd Jul 2023, 1:45 PM
Shizuo
- 1
It's not working
16th Jan 2021, 9:29 AM
PARUCHURI YASWANTH
PARUCHURI YASWANTH - avatar
- 1
#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; }
16th Jan 2021, 9:40 AM
PARUCHURI YASWANTH
PARUCHURI YASWANTH - avatar
- 1
Actual output is 8888 is a palindrome
16th Jan 2021, 9:40 AM
PARUCHURI YASWANTH
PARUCHURI YASWANTH - avatar
- 1
Iam trying a lot But it won't works sir
16th Jan 2021, 9:51 AM
PARUCHURI YASWANTH
PARUCHURI YASWANTH - avatar