- Home
- Course Category
- Course Result
- Course Detail
Hot Line: 0124-2383121
Course Introduction
Programs for practice
Following C++ program ask the user to enter a number, to find its reverse and then check whether reverse is equal to its original or not, then display the result on the screen: in C++
Source Code: Check Original Equal Reverse or Not (Palindrome or not)
/* C++ Program - Check Original Equal Reverse or Not */
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int num, orig, rev=0, rem;
cout<<"Enter a number : ";
cin>>num;
orig=num;
while(num>0)
{
rem=num%10;
rev=rev*10+rem;
num=num/10;
}
if(orig==rev)
{
cout<<"Reverse is equal to original";
}
else
{
cout<<"Reverse is not equal to original";
}
getch();
}
Output
Enter a Number: 12321
Reverse is equal to original