Tuesday 24 March 2015

Program 1 : PALINDROME NUMBER

PALINDROME NUMBER IS A NUMBER WHICH ON REVERSING REMAINS IN THE SAME ORDER.
EXAMPLE: 121 , 1441 , 153351

PROGRAM :

 import java.util.Scanner;
public class assign1
{
    public static void main(String args[]){
         Scanner sc = new Scanner(System.in);
         System.out.println("enter a number to find out whether it is a palindrome number or not:");
         int num = sc.nextInt();
         int q = num;
         int dig , r = 0;
         while(q!=0){
             dig = q%10;
             r = (r*10) + dig;
             q = q/10;
         }
         if(r==num){
             System.out.println("The number entered is palindrome.");
            }
         else {
             System.out.println("The number entered is not a palindrome");
            }
        }
    }

 

2 comments:

  1. Commendable job. Request if you can add comments within program to understand very well.

    ReplyDelete
  2. THANK YOU. I HAVE ADDED COMMENTS IN THE NEW PROGRAMS.

    ReplyDelete