Check whether a number is palindrome or not
Write a C++ program to Check whether a number is palindrome or not using while loop. Here’s simple program to Check whether a number is palindrome or not using while loop in C++ Programming Language.
A Palindrome number is a number that remains the same when its digits are reversed.
For example: we take 121 and reverse it, after reverse it is same as original.
Here is source code of the C++ program to Check whether a number is palindrome or not using while loop. The C++ program is successfully compiled and run(on Codeblocks) on a Windows system. The program output is also shown in below.
SOURCE CODE : :
/* C++ program to Check whether a number is palindrome or not */ #include<iostream> using namespace std; int main() { int a,no,b,temp=0; cout<<"Enter any positive number :: "; cin>>no; b=no; while(no>0) { a=no%10; no=no/10; temp=temp*10+a; } if(temp==b) { cout<<"\nThe Number [ "<<b<<" ] is Palindrome.\n"; } else { cout<<"\nThe Number [ "<<b<<" ] is Not Palindrome.\n"; } return 0; }
Output : :
/* C++ program to Check whether a number is palindrome or not */ Enter any positive number :: 12321 The Number [ 12321 ] is Palindrome. Process returned 0
Above is the source code for C++ program to Check whether a number is palindrome or not which is successfully compiled and run on Windows System.The Output of the program is shown above .
If you found any error or any queries related to the above program or any questions or reviews , you wanna to ask from us ,you may Contact Us through our contact Page or you can also comment below in the comment section.We will try our best to reach up to you in short interval.
Thanks for reading the post….