76 316
Assignments Done
Successfully Done
In May 2019

Answer to Question #21284 in C++ for Syeda Wajiha Quadri

Question #21284
Program to find the sum of the series 1+2+3...+n
Program to find the sum of the series 1(pow)+2(pow)+3(pow)...+n(pow)
Expert's answer
#include <iostream>
#include <conio.h>
#include <math.h>

using namespace std;

long sum_1(int n)
return n * (1 + n) / 2;

long sum_2(int n, int m)
long result = 0;
for (n; n > 0; n--)
result += (long)pow((long double)n, m);
return result;

void main()
int n, m;
cout << "Enter n: ";
cin >> n;
cout << "Enter m: ";
cin >> m;

cout << "The sum of the 1st series is: " << sum_1(n) << endl;
cout << "The sum of the 2nd series is: " << sum_2(n, m) << endl;

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!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions