# Pallindrome

Programming
account_circle Unassigned
schedule 1 Day
account_balance_wallet \$5

Program for Pallindrome NUmber
Mar 19th, 2018

# C Program to Check Whether a Number is Palindrome or Not

This program takes an integer from user and that integer is reversed. If the reversed integer is equal to the integer entered by user then, that number is a palindrome if not that number is not a palindrome.

## C Program to Check Palindrome Number

``````/* C program to check whether a number is palindrome or not */#include<stdio.h>int main(){int n, reverse=0, rem,temp;
printf("Enter an integer: ");
scanf("%d",&n);
temp=n;while(temp!=0){
rem=temp%10;
reverse=reverse*10+rem;
temp/=10;}/* Checking if number entered by user and it's reverse number is equal. */if(reverse==n)
printf("%d is a palindrome.",n);else
printf("%d is not a palindrome.",n);return0;}``````

Output

```Enter an integer: 12321
12321 is a palindrome.```

# Java program to find whether no. is palindrome or not

package testing;
import java.util.Scanner;

/**
* Java program to check if number is palindrome or not.
* A number is called palindrome if number and its reverse is equal
* This Java program can also be used to reverse a number in Java
*/
public class NoClassDefFoundErrorDueToStaticInitFailure {

public static void main(String args[]){

System.out.println("Please Enter a number : ");
int palindrome = new Scanner(System.in).nextInt();

if(isPalindrome(palindrome)){
System.out.println("Number : " + palindrome + " is a palindrome");
}else{
System.out.println("Number : " + palindrome + " is not a palindrome");
}

}

/*
* Java method to check if number is palindrome or not
*/

public static boolean isPalindrome(int number) {
int palindrome = number; // copied number into variable
int reverse = 0;

while (palindrome != 0) {
int remainder = palindrome % 10;
reverse = reverse * 10 + remainder;
palindrome = palindrome / 10;
}

// if original and reverse of number is equal means
// number is palindrome in Java
if (number == reverse) {
return true;
}
return false;
}

}

Output:
123
Number : 123 is not a palindrome
121
Number : 123 is a palindrome

Please rate this answer as the best answer if you are satisfied as this is how I receive credit for my work. Thank you.

May 31st, 2013

...
Mar 19th, 2018
...
Mar 19th, 2018
Mar 20th, 2018
check_circle