"KEEP LEARNING, DON'T STOP."
"KEEP LEARNING, DON'T STOP."
In this section you will learn how to make palindrome number program in c++. We will use while loop condition to perform palindrome number check operation.
A palindrome number is a number such that if you reverse it, it will not change. The number should be remain same. To check whether a number is palindrome or not first we reverse it and then compare the number obtained with the original, if both are same then number is palindrome otherwise not.
212, 121, 77077, 11611.
#include<iostream.h> #include<conio.h> //PALINDROME NUMBER PROGRAM void main() { int n, reverse=0, temp; clrscr(); cout<<"ENTER A NUMBER TO CHECK PALINDROME OR NOT:- "; cin>>n; temp = n; while (temp != 0) { reverse = reverse * 10; reverse = reverse + temp % 10; temp = temp / 10; } if (n == reverse) { cout<<"ENTER NUMBER IS PALINDROME."; } else { cout<<"ENTER NUMBER IS NOT PALINDROME."; } getch(); }
ENTER A NUMBER TO CHECK PALINDROME OR NOT :- 777 ENTER NUMBER IS PALINDROME.