67 257
Assignments Done
99,3%
Successfully Done
In November 2018

Answer to Question #19071 in C++ for kshitij

Question #19071
write a program to print the sum of the following series : 1+16+49+100+169
Expert's answer
#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();
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions