Searching...

Sum of Series

15:32

write a program that will calculate the sum of series:   x+x2+x3+...............+xn
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
int n_value,x_value,sum=0;
cout << "Enter The value of X: ";
cin >>x_value;
cout << "Enter The value of N: ";
cin >>n_value;
for (int i=1;i<=n_value;i++)
{
sum=sum + pow(x_value,i);
}
cout << "Sum is: " << sum <<endl;
return 0;
}

0 comments:

Post a Comment

Thanks For Your FeedBack....

:) :)) ;(( :-) =)) ;( ;-( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ $-) (b) (f) x-) (k) (h) (c) cheer
Click to see the code!
To insert emoticon you must added at least one space before the code.