CPP
cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <iostream>
using namespace std;
/* A palindrome is a number which reads the same backward or forward. */
int main()
{
// sample number
int num = 23532;
//reverse the number
int r, temp;
int sum = 0;
for(temp = num; num != 0; num /= 10)
{
r = num % 10;
sum = sum * 10 + r;
}
//compare the numbers
if(temp == sum)
cout << temp << " is a palindrome";
else
cout << temp << " is not a palindrome";
return 0;
}
Enter to Rename, Shift+Enter to Preview
OUTPUT
Ejecutar