Centered Square Number | C ++ program to find nth Centered square number . ; Function to calculate Centered square number function ; Formula to calculate nth Centered square number ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int centered_square_num ( int n ) { return n * n + ( ( n - 1 ) * ( n - 1 ) ) ; } int main ( ) { int n = 7 ; cout << n << " th ▁ Centered ▁ square ▁ number : ▁ " ; cout << centered_square_num ( n ) ; return 0 ; }