Programming Blog

This blog is about technical and programming questions and there solutions. I also cover programs that were asked in various interviews, it will help you to crack the coding round of various interviews

Saturday, 30 December 2017

Another method palindrome in java


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