I need a c++ program to print the sum of series, 2 +(2+4) +(2+4+6) +........+ nth term.
N to be obtained from the user.
Answers
Answered by
0
#include <iostream>
main () {
int N, i, term , j , sum ;
cin >> N;
for ( i=0, sum=0; i < N ; i++ ) {
for (j=0, term=0; j < i; j++ )
term += 2;
sum += term;
}
cout << sum ;
}
main () {
int N, i, term , j , sum ;
cin >> N;
for ( i=0, sum=0; i < N ; i++ ) {
for (j=0, term=0; j < i; j++ )
term += 2;
sum += term;
}
cout << sum ;
}
Similar questions