Find the sum of all the terms in the n | C ++ implementation to find the sum of all the terms in the nth row of the given series ; function to find the required sum ; sum = n * ( 2 * n ^ 2 + 1 ) ; Driver program to test above
#include <bits/stdc++.h> NEW_LINE using namespace std ; int sumOfTermsInNthRow ( int n ) { int sum = n * ( 2 * pow ( n , 2 ) + 1 ) ; return sum ; } int main ( ) { int n = 4 ; cout << " Sum ▁ of ▁ all ▁ the ▁ terms ▁ in ▁ nth ▁ row ▁ = ▁ " << sumOfTermsInNthRow ( n ) ; return 0 ; }