u

Wednesday 6 June 2012

C++ Program for computation of:Natural Log (Ln),Log with Base 10(Log10),Log of your desired Base (LogA^x)

C++ Program for computation of:

1). Natural Log (Ln)
2). Log with Base 10(Log10)
3).Log of your desired Base (LogA^x)


#include<iostream.h>
#include<iomanip.h>
#include<stdlib.h>
#include<dos.h>
#include<conio.h>
#include<math.h>

class logarithem


    {
    protected:
    long ans;
    public:
     logarithem():ans(0)


         {
         /* cout<<"Enter the value of 'X':";
        cin>>ans; */
         }
        double loga(double);
        double ln(double x);
        double checking(double);
    };
    double logarithem::loga(double b)


    {
    double LOG10=0,c;
    c=ln(b);
    LOG10=c/2.30258509299404;
    return LOG10;
    }
    double logarithem:: ln(double x)


    {
        double lnX=0.000001,check;


        do{
            lnX=lnX-(exp(lnX)-x)/exp(lnX);
            check=checking(lnX);
         }while(check!=0);
        return lnX;
    }
    double logarithem::checking(double x)


        {
        static double x1=0;
        double x2;
         if(x1==0)


            {
             x1=x;
             return 1;
            }
             else


             {
                 x2=x1-x;
                 if(x2<0)
                x2*=-1;
                x1=x;
            return x2;
             }
        }
        void main()


            {
            clrscr();
            logarithem a;
            double b=0,k=0;
            int opt1;
            char ch;
                clrscr();
                highvideo();
                textcolor(BLACK);
                textbackground(3);
                one:
                cout<<"\n1. For Natural Log (ln) ";
                cout<<"\n2. For Log of Base 10";
                cout<<"\n3. For Log of x with Base a, Log a^x = Logx/Loga";
                cout<<"\n4. For Exit";
                cout<<"\n ";
                cout<<"\n\n\n\tEnter Your Option:- ";
                cin>>opt1;
             switch(opt1)


                 {
                 case 2:
                    cout<<"\n\nEnter the value of X : ";
                    cin>>b;
                    cout<<"\n\n\t( Log_10^"<<b<< " is "<<a.loga(b)<<" )";
                    cout<<endl<<"\n\tPress any key to go back....";
                    ch=getch();
                    if(ch=='\r')
                    clrscr();
                    goto one;
                 case 1:
                     cout<<"\n\nEnter the value of X"<<"\t";
                     cin>>b;
                     cout<<"\n\n\t( Ln "<<b<<" : "<<a.ln(b)<<" )";
                     cout<<endl<<"\n\tPress any key to go back....";
                     ch=getch();
                     if(ch=='\r')
                     clrscr();
                     goto one;
                 case 3:
                     cout<<"\n\nEnter the value of a :"<<"\t";
                     cin>>b;
                     cout<<"\nEnter the value of x :"<<"\t";
                     cin>>k;
                     cout<<"\n\n\t( Log a^x = Logx/Loga "<<b<<" : "<<a.ln(k)/a.ln(b)<<" )";
                     cout<<endl<<"\n\tPress any key to go back....";
                     ch=getch();
                     if(ch=='\r')
                     clrscr();
                     goto one;
                 case 4:
                    delay(100);
                    exit(0);
                 default:
                    cout<<"\n\n\tPlease! Enter the options shown above ...";
                    cout<<endl<<"\n\tPress any key to go back....";
                    ch=getch();
                    if(ch=='\r')
                    clrscr();
                    goto one;
                 }

            }

1 comments:

Sega Genesis/Mega Drive - The King of Dealer
› blog › mega-drive-2 › blog › mega-drive-2 Mar 26, 2019 — Mar 26, 2019 This new 카지노 사이트 Retro game is kirill-kondrashin intended for the Sega Genesis/Mega Drive. This time around, the Sega Megadrive, in this retro game you can experience world of first class

Post a Comment

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More