-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreverse_num.java
More file actions
34 lines (32 loc) · 965 Bytes
/
Copy pathreverse_num.java
File metadata and controls
34 lines (32 loc) · 965 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
import java.util.*;
public class reverse_num
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter a number: ");
int num = sc.nextInt();
int temp = num ;
int rev = 0;
int count = 0;
int sum = 0;
while(temp!= 0)
{
int digit = temp%10;
sum = sum+digit;
rev = rev*10+digit;
temp = temp/10;
count++;
}
System.out.println("The reverse is: " + rev);
System.out.println("The count of number is: " + count);
System.out.println("The sum of number is: " + sum);
if(num == rev && num>9){
System.out.println("The given number is palindrome");
}
else{
System.out.println("THe given number is not a palindrome");
}
sc.close();
}
}