5th sem OOPJ Write a program to find that given number or string is palindrome or not.

import java.io.*;
import java.util.*;

/**
 *
 * @author Yash
 */

class pra7{
    public static void main(String arg[]){
       
        Scanner sc = new Scanner(System.in);
       
        System.out.println("Enter String :");
        int n = sc.nextInt();
       
        int r,sum=0,temp;  
     
 
        temp=n;  
        while(n>0){  
        r=n%10;  //getting remainder
        sum=(sum*10)+r;  
        n=n/10;  
            }  
        if(temp==sum)  
            System.out.println("palindrome number ");  
        else  
            System.out.println("not palindrome");
    }  
}

Comments

Popular posts from this blog

5th sem OOPJ Write an interactive program to print a diamond shape. For example, if user enters the number 3, the diamond will be as follows:

SQL Lab1: Create a Database Table for DayCare

SQL Lab 11