Palindrome Number Program in Java
Hello, friends, Hitesh is here; Here we will write the complete code of Palindrome Number Program in Java. This type of number is the same when you reverse it, here some tips and concepts are applied which is used in C programming only change the syntax.
Code of Java Program to Check Number is Palindrome or Not
import java.util.*;
public class PalindromeExample
{
public static void main(String s[])
{
int temp=0,d=0,rem=0;
temp=t;
System.ot.println("Enter any number: ");
Scanner c= new Scanner(System.in);
int t=c.nextInt();
while(t>0)
{
d=t%10;
rem=rem*10+d; t=t/10;
}
System.out.println("Reverse of Number is "+rem);
if(r==temp)
System.out.println("Number is Palindrome");
else
System.out.println("Number is not Paliundrome");
}
}
Output:
Enter any number: 121
Number is Palindrome
No comments:
Post a Comment