Programming
Pallindrome

Question Description

Program for Pallindrome NUmber

Final Answer

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:
Please Enter a number : 
123
Number : 123 is not a palindrome
Please Enter a number : 
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. 



Duke University

Anonymous
Solid work, thanks.

Anonymous
The tutor was great. I’m satisfied with the service.

Anonymous
Goes above and beyond expectations !

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors