Lập Trình C/C++ - Palindrome Number


#Code:
#include<iostream>
using namespace std;

int main()
{
 int no, temp, palindrome = 0;
 cout << "Check the given number is Palindrome or not" << endl;
 cout << "Enter a Number:" << endl;
 cin >> no;
 temp = no;

 /* Loop the process using "While loop" */
 while(temp != 0)
 {
  palindrome = palindrome * 10;
  palindrome = palindrome + (temp % 10);
  temp = temp / 10;
 }

 if(no == palindrome)
  cout << "It's a Palindrome Number!" << endl;
 else
  cout << "It's not a Palindrome Number!" << endl;

 return 0;
}

0 Comment:

Đăng nhận xét

Thank you for your comments!