-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDay21.java
More file actions
47 lines (34 loc) · 680 Bytes
/
Day21.java
File metadata and controls
47 lines (34 loc) · 680 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
Day 21 coding Statement : Write a program to identify if the number is Palindrome or not
Description
Get a number as input from the user and check whether that number is a Palindrome or not.
Input
121
Output
Palindrome
Input
34
Output
Not a Palindrome
*/
import java.util.*;
public class Day21
{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n,q,rev=0;
System.out.println("Enter a number : ");
n = sc.nextInt();
q=n;
while(n>0){
int rem=n%10;
rev = rev*10+rem;
n/=10;
}
if(q==rev){
System.out.println("Palindrome");
}else{
System.out.println("Not Palindrome");
}
}
}