Skip to main content

Write a Program in java to accept a number and check whether the number is palindrome or not

Write a Program in java to accept a number and check whether the number is palindrome or not.



import java.util.Scanner; 
public class palindromeNumber { 
public static void main(String[] args) { 
Scanner sc = new Scanner(System.in); 
System.out.println("Enter the number : "); 
int n = sc.nextInt(); 
isPallindrome(n); 
sc.close(); 
public static void isPallindrome(int n) { 
int num = n; 
int reverse = 0; 
while (num > 0) { 
int rem = num % 10; 
reverse = reverse * 10 + rem; 
num /= 10; 
if (reverse == n) 
System.out.println(n + " is Palindrome Number."); 
else
System.out.println(n + " is not Palindrome Number."); 
}


OUTPUT: 

Enter the number :
1331
1331 is Palindrome Number


Comments

Popular posts from this blog

JS Code for Generating OTP

JS Code for Generating OTP -  * Learn how to create a simple JavaScript function to generate a random 4-digit OTP. (GENERATED BY - ChatGPT) function OTP() { let otp = ""; otp = Math.floor(Math.random() * 9000 + 1000); return otp; } console.log("Your OTP is-", OTP());

What is E. coli? What is it use as a model organism in Metabolic engineering?

What is E. coli? Ans.   E. coli is a Gram-negative rod-shaped bacterium that is typically around 1 μm long and 0.35 μ m wide. It is able to survive with or without oxygen and thus is a "facultative aerobe". Although it is able to grow fast without forming clumps in various inexpensive chemically defined media, it is not typically tolerant to very high or low temperatures or extreme acidity/alkalinity. Its potential for fast growth, the number of molecular techniques for genetic manipulations available, and a good amount of knowledge about its genetics mean that it has the versatility to be utilized in many ways. Also,  E. coli  mainly replicates asexually, meaning that modifications made to the genome are maintained and thus effects seen in these mutants are reproducible. These factors make  E. coli  a good model organism for molecular genetics. E. Coli Symptoms Ans.   Symptoms of  E. coli  typically set in within 2-3 days of infection. Symptoms ...

Top 10 Most Famous Photographers of All Time

*Top 10 Most Famous Photographers of All Time* If you want to take truly memorable and moving photographs, you can learn something by studying the pictures of famous photographers. Some of the most beloved artists are deceased, but some are still delighting us with their photographs. The list below includes some of the more famous photographers that still impact our lives today. 1. *Ansel Adams* is probably the most easily recognized name of any photographer. His landscapes are stunning; he achieved an unparalleled level of contrast using creative darkroom work. You can improve your own photos by reading Adams’ own thoughts as he grew older, when he wished that he had kept himself strong enough physically to continue his work. 2. *Yousuf Karsh* has taken photographs that tell a story, and that are more easily understood than many others. Each of his portraits tells you all about the subject. He felt as though there was a secret hidden behind each woman and man. Whether he captures a gl...