-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPalindrome.cpp
More file actions
32 lines (25 loc) · 871 Bytes
/
Palindrome.cpp
File metadata and controls
32 lines (25 loc) · 871 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*
Palindrome number in c: A palindrome number is a number such that if we reverse it,
it will not change. For example some palindrome numbers examples are 121, 212, 12321,
-454. 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.
C++ program for palindrome number is given below.*/
#include<iostream.h>
int main()
{
int n, reverse = 0, temp;
cout<<"Enter a number to check if it is a palindrome or not\n";
cin>>\n;
temp = n;
while( temp != 0 )
{
reverse = reverse * 10;
reverse = reverse + temp%10;
temp = temp/10;
}
if ( n == reverse )
cout<<n<<" is a palindrome number.\n";
else
cout<<n<<" is not a palindrome number.\n";
return 0;
}