I have to write a programme r=1/x+2/x^2+3/x^3+....n/x^n i write the program but cant get the answer can someone correct me faster plzz

//#include <iostream>
//using namespace std;
//int main()
//{
//int n=0,i=0,j=0;
//double x=0,r=0;
//double numerator,denominator;


//cout<<"Please enter a value for n:";
//cin>>n;
//cout<<"Please enter a value for x:";
//cin>>x;
//r=0;


//for(i=1;i<=n;i++)
//{
//  numerator=0;
//  denominator=0;
//  for (j=1;j<=n;j++)
//  {
//      numerator+=x;
//      denominator+=j;
//  }
//  r=r+numerator/denominator;
//}
//cout<<"The result is"<<r<<endl;
//return 0;
//}

sorry for my mistake !!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.