write a program to print the sum of the following series : 1+16+49+100+169
1
Expert's answer
2012-11-20T10:06:11-0500
#include <iostream> #include <conio.h>
using namespace std;
long long CalculateSum(int seriesLength) { long long result = 0; int number = 1;
for (int k = 0; k < seriesLength; k++, number += 3) & result += number * number; return result; }
void main() { int seriesLength; cout << "Enter the length of the series: "; cin >> seriesLength; cout << "The sum of the series is: " << CalculateSum(seriesLength); getch(); }
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment