text: Sum of series with alternate signed squares of AP | Efficient CPP program to find sum of series with alternate signed square AP sums . ; function to calculate series sum ; Driver code
code: #include <bits/stdc++.h> NEW_LINE using namespace std ; int seiresSum ( int n , int a [ ] ) { return n * ( a [ 0 ] * a [ 0 ] - a [ 2 * n - 1 ] * a [ 2 * n - 1 ] ) / ( 2 * n - 1 ) ; } int main ( ) { int n = 2 ; int a [ ] = { 1 , 2 , 3 , 4 } ; cout << seiresSum ( n , a ) ; return 0 ; }