Number of cells in the Nth order figure | C ++ implementation of the approach ; Function to return the number of cells in the nth order figure of the given type ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int cntCells ( int n ) { int cells = pow ( n , 2 ) + pow ( n - 1 , 2 ) ; return cells ; } int main ( ) { int n = 3 ; cout << cntCells ( n ) ; return 0 ; }