Count of perfect squares of given length | C ++ Program to count perfect squares of given length ; Function to return the count of n digit perfect squares ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int countSquares ( int n ) { int r = ceil ( sqrt ( pow ( 10 , n ) ) ) ; int l = ceil ( sqrt ( pow ( 10 , n - 1 ) ) ) ; return r - l ; } int main ( ) { int n = 3 ; cout << countSquares ( n ) ; return 0 ; }