# 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();

}

#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 orderand get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

## Comments

## Leave a comment