Powered by Blogger.

Palindrome Number Program in C++



Palindrome Number Program in C++

Hello coder here we write palindrome number program in c++ or some time you can get C++ Program to Check Number is Palindrome or Not. To write this program first get input from use and revers this number, in next step compare output with original number, if both are same it means input number by user is palindrome otherwise not palindrome number.

Example of Palindrome number Program in C++

#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 << " The reverse of the number is: " << rev << endl;
     if (n == rev)
         cout << " The number is a palindrome";
     else
         cout << " The number is not a palindrome";
    return 0;
}

Output

Enter a positive number: 121
The reverse of the number is: 121
The number is a palindrome 
Enter a positive number: 123
The reverse of the number is: 321
The number is not a palindrome



facebook
google-plus
twitter
pinterest

No comments :

Post a Comment

HTML Tutorial

images

About Sitesbay

This blog is related to Java Tutorial, C++ Tutorial, C Tutorial, Online Earning tips and more in very simple and easy way. Here i will try to give complete idea related to all new technology.

Java Tutorial

Java is Object oriented programming language, It is more secure and high performance language.

C++ Tutorial

C++ is also Object oriented programming language, It is more simple and easy to learn.

 
https://sitesbay.blogspot.com/?utm_medium=d2898efa59afcc0bc411921036e22b767ca37b09