Write a program to read a 3-digit number and find whether it is a digit palindrome or not.
Answers
Answered by
4
The given problem is solved using language - Java.
import java.util.*;
public class Brainly{
public static void main(String s[]){
Scanner sc=new Scanner(System.in);
System.out.print("Enter a three digit number: ");
int n=sc.nextInt();
sc.close();
if(n%10==n/100)
System.out.println("Palindrome.");
else
System.out.println("Not Palindrome.");
}
}
- A number is said to be palindrome if it is equal to its reverse.
- Example, 343 is palindrome.
- A three digit number is said to be palindrome if the first and last digit are same.
- Using this logic, the problem is solved.
See attachments for output.
Attachments:
Similar questions