Write a program in Java to print all palindromic numbers between 150-250.
Answers
Answered by
0
Answer:
class GFG
{
// A function to check
// if n is palindrome
static int isPalindrome(int n)
{
// Find reverse of n
int rev = 0;
for (int i = n; i > 0; i /= 10)
rev = rev * 10 + i % 10;
// If n and rev are same,
// then n is palindrome
return(n == rev) ? 1 : 0;
}
static void countPal(int min, int max)
{
for (int i = min; i <= max; i++)
if (isPalindrome(i)==1)
System.out.print(i + " ");
}
public static void main(String args[])
{
countPal(150, 250);
}
}
Similar questions
Social Sciences,
1 month ago
Physics,
1 month ago
Accountancy,
1 month ago
Physics,
2 months ago
Math,
10 months ago
Math,
10 months ago