Skip to content

Commit 287e8c5

Browse files
palindrome number
a palindrome number is a number such that when the digits are reversed, the result gives the original number itself.
1 parent 7af6a7e commit 287e8c5

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

palindrome.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import java.util.*;
2+
class palindrome
3+
{
4+
public static void main()
5+
{
6+
Scanner sc= new Scanner(System.in);
7+
System.out.println("enter a number");
8+
int num= sc.nextInt();
9+
int d,num1,rev;rev=0;
10+
num1=num;
11+
while(num!=0)
12+
{
13+
d=num%10;
14+
rev=rev*10+d;
15+
num=num/10;
16+
}
17+
if(num1==rev)
18+
System.out.println("the number is palindromic");
19+
else
20+
System.out.println("the number is not palindromic");
21+
}
22+
}
23+
24+
25+
26+
27+

0 commit comments

Comments
 (0)