Sum of all the numbers in the Nth row of the given triangle | C ++ implementation of the approach ; Function to return the sum of the nth row elements of the given triangle ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int getSum ( int n ) { return ( ( n - 1 ) + pow ( n , 2 ) ) ; } int main ( ) { int n = 3 ; cout << getSum ( n ) ; return 0 ; }