Find all palindrome numbers of given digits | C # implementation of the approach ; Function to return the reverse of num ; Function that returns true if num is palindrome ; If the number is equal to the reverse of it then it is a palindrome ; Function to print all the d - digit palindrome numbers ; Smallest and the largest d - digit numbers ; Starting from the smallest d - digit number till the largest ; If the current number is palindrome ; Driver code
using System ; class GFG { static int reverse ( int num ) { int rev = 0 ; while ( num > 0 ) { rev = rev * 10 + num % 10 ; num = num / 10 ; } return rev ; } static bool isPalindrome ( int num ) { if ( num == reverse ( num ) ) return true ; return false ; } static void printPalindromes ( int d ) { if ( d <= 0 ) return ; int smallest = ( int ) Math . Pow ( 10 , d - 1 ) ; int largest = ( int ) Math . Pow ( 10 , d ) - 1 ; for ( int i = smallest ; i <= largest ; i ++ ) { if ( isPalindrome ( i ) ) Console . Write ( i + " ▁ " ) ; } } public static void Main ( String [ ] args ) { int d = 2 ; printPalindromes ( d ) ; } }