English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

X+X^2+X^3........X^n-j

2007-03-09 20:18:04 · 2 answers · asked by sirf _tum 1 in Computers & Internet Programming & Design

2 answers

#include #include
#include
void main()
{
int x,j,n;
long int sum;
cout<<"enter the value for x"< cin>>x;
cout<<"enter the value for n and j"< cin>>n>>j;
sum=0;
for(int i=0;i<=j;i++)
{
sum=sum+pow(x,i);
}
cout<<"sum = "< }

2007-03-09 20:38:46 · answer #1 · answered by aravind0609 1 · 0 0

I'm not going to do all the work for you. That way you'll never learn.

Have a variable x
Use a for loop for i=1 to 1=n-j
each time round the for loop, have x+=x^i

2007-03-10 04:21:22 · answer #2 · answered by Yanni Depp 6 · 0 0

fedest.com, questions and answers