Advertisements
Advertisements
प्रश्न
Write a program to check if a number is a numeric palindrome.
कोड लेखन
Advertisements
उत्तर
import java.util.*;
class clDigits
{
void main()
{
Scanner sc = new Scanner(System.in);
int N, revn = 0, cn = 0, d = 0;
System.out.print("Enter a number: ");
N = sc.nextInt();
cn = N;
while(cn > 0)
{
d = cn % 10;
revn = revn * 10 + d;
cn = cn / 10;
}
if(N == revn)
{
System.out.print(N + " is a Numeric Palindrome.");
}
else
{
System.out.print(N + " is Not a Numeric Palindrome.");
}
}
}
Output:
Enter a number : 2332
2332 is a Numeric Palindrome.
Enter a number : 135
135 is Not a Numeric Palindrome.
shaalaa.com
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
