Thursday 19 June 2014

C++ program to generate logarithmic series



Here is a C++ program to generate logarithmic series


 SOURCE CODE OUTPUT
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
    long double n,x;
    long double an=0;
    cout<<"Enter first term (ln(x)) ";
    cin>>x;
    cout<<"Enter the value of n ";
    cin>>n;
    for(int y=1;y<=n;y++)
    {
        an+=pow(x-1,y)/(1.0*y*pow(x,y));
    }
    cout<<"ln("<<x<<") = "<<an;
    return 0;
}

Any questions regarding to program please write in comments.

No comments:

Post a Comment