Write a program to display the summation of the following series :
12 + 32 + 52 + 72 + 92 + 112 + 132
+ 152
#include <iostream>
#include<vector>
using namespace std;
int main()
{
vector<int>series = {12,32,52,72,92,112,132,152};
int sum = 0;
for(int i = 0; i < int(series.size()); i++){
sum += series[i];
}
cout<<"Sum of the given series is : "<<sum<<"\n";
return 0;
}
Comments
Leave a comment