Count of squares that can be drawn without lifting the pencil | C ++ implementation of the approach ; Function to return the count of squares that can be formed ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int countSquares ( int n ) { return ( pow ( n , 2 ) - ( 2 * n ) + 2 ) ; } int main ( ) { int n = 2 ; cout << countSquares ( n ) ; return 0 ; }