------------------------------------------------------------------------------------------------------------------
Palindrome Number Try It🔻
------------------------------------------------------------------------------------------------------------------#include <iostream>
using namespace std;
int main()
{
int n, num, digit, rev = 0;
cout << "Enter a positive number: ";
cin >> num;
n = num;
do
{
digit = num % 10;
rev = (rev * 10) + digit;
num = num / 10;
} while (num != 0);
cout <<endl<< "The reverse of the number is: " << rev << endl;
if (n == rev)
cout <<endl<<"The number is a palindrome";
else
cout <<endl<<"The number is not a palindrome";
return 0;
}
------------------------------------------------------------------------------------------------------------------
OUTPUT Try It🔻
------------------------------------------------------------------------------------------------------------------
Enter a positive number: 12345
The reverse of the number is: 54321
The number is not a palindrome
//Run Again
Enter a positive number: 12321
The reverse of the number is: 12321
The number is a palindrome
Palindrome Number Try It🔻
------------------------------------------------------------------------------------------------------------------#include <iostream>
using namespace std;
int main()
{
int n, num, digit, rev = 0;
cout << "Enter a positive number: ";
cin >> num;
n = num;
do
{
digit = num % 10;
rev = (rev * 10) + digit;
num = num / 10;
} while (num != 0);
cout <<endl<< "The reverse of the number is: " << rev << endl;
if (n == rev)
cout <<endl<<"The number is a palindrome";
else
cout <<endl<<"The number is not a palindrome";
return 0;
}
OUTPUT Try It🔻
------------------------------------------------------------------------------------------------------------------
Enter a positive number: 12345
The reverse of the number is: 54321
The number is not a palindrome
//Run Again
Enter a positive number: 12321
The reverse of the number is: 12321
The number is a palindrome