Smallest and Largest N | C ++ implementation of the approach ; Function to print the largest and the smallest n - digit perfect squares ; Smallest n - digit perfect square ; Largest n - digit perfect square ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; void nDigitPerfectSquares ( int n ) { cout << pow ( ceil ( sqrt ( pow ( 10 , n - 1 ) ) ) , 2 ) << " ▁ " ; cout << pow ( ceil ( sqrt ( pow ( 10 , n ) ) ) - 1 , 2 ) ; } int main ( ) { int n = 4 ; nDigitPerfectSquares ( n ) ; return 0 ; }