- 4
Palindrome numbers project answer?😢
Please
7 Réponses
+ 4
Hello مصطفى المهدي
Please show us your attempt.
+ 3
Please mention language as well as attach your code....
+ 3
Is it the code project from the sololearn course?
What is "example"? It is never declared???
Don't hard code the number – it is input and may vary.
One way to approach it, is to make the number as string and construct another a string that is the reversion of the number string. Than you can compare the 2 strings – if they are equal, return true, else false
+ 2
/***Try this***/
bool isPalindrome(int x) {
int y=x;
int z=0;
while(x){
z=z*10+x%10;
x=x/10;
}
return y==z;
}
0
C++please help
0
#include <iostream>
using namespace std;
bool isPalindrome(int x) {
x=example;
example=8888;
}
int main() {
int n;
cin >>n;
if(!isPalindrome(n)) {
cout <<n<<" is a palindrome";
}
else {
cout << n<<" is NOT a palindrome";
}
return 0;
0
Thanks Lisa 😁😁