Code:
//I)
to check a number is Palindrome or not.
#include<iostream>
using namespace std;
void main()
{
cout << "\t\t\tPlindrome Number\n\n";
int num, rev, tmp, tmp2, i, j, rev1;
rev = 0; i = 0; j = 1; rev1 = 0;
cout << "Enter A Nmuber : ";
cin >> num;
tmp = num;
while (tmp != 0) //to
calculate reverse
{
tmp2 = tmp % 10; //number remainder 10 will assign to tmp2
rev = rev * 10 + tmp2; //reverse of number is equal to rev*10+number%10
tmp = tmp / 10; //updating the value of number
}
if (rev == num) //if
reverse is equal to number
{
cout <<endl<< num
<< " Is Pandlirome.";
}
else //if reverse is not equal to
number
{
cout <<endl<< num
<< " Is Not Palindrome.";
}
cout << "\n\n";
system("pause");
0 comments:
Post a Comment