Smallest and Largest Palindrome with N Digits | C ++ implementation of the above approach ; Function to print the smallest and largest palindrome with N digits ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; void printPalindrome ( int n ) { if ( n == 1 ) { cout << " Smallest ▁ Palindrome : ▁ 0" << endl ; cout << " Largest ▁ Palindrome : ▁ 9" ; } else { cout << " Smallest ▁ Palindrome : ▁ " << pow ( 10 , n - 1 ) + 1 ; cout << " Largest Palindrome : " } } int main ( ) { int n = 4 ; printPalindrome ( n ) ; return 0 ; }