java program to check palindrome using simple logic
import java.util.Scanner;public class JavaProgram{public static void main(String args[]){int num, rem, orig_num, rev=0;Scanner scan = new Scanner(System.in);System.out.print("Enter a Number : ");num = scan.nextInt();orig_num = num;while(num != 0){rem = num%10;rev = rev*10 + rem;num = num/10;}if(rev==orig_num){System.out.print("This is a Palindrome Number");}else{System.out.print("This is not a Palindrome Number");}}}
No comments:
Post a Comment