Im adding a specialised formula to a calculator, and it uses the Ln/ln function which is often on scientific calculators, how do i get this function to work in c++?
The formula is as follows:
'formula: pl * (10*diff + 10*creat +2*lines)
150 * (Ln(pl/1.5))'
Can anyone help?

#include <cmath>

Use the 'log' function (which computes the natural logarithm).

When i have that in it gives an error saying that the log hasnt been initialised, maybe youll understand it better if you look at the code:

#include <iostream>
#include <cmath>

using namespace std;

int main()
        char name [100];
        char quit;
        quit ='\0';
        while (quit !='q')
                system("title AnimeDD Power Level Calculator");
                system("color 84");
                float creat, diff, lines, pl, log, x, y, z; //loads integers into memory
                cout <<"This is a simple power level calculator"<< endl;
                cout<<"What is your characters name?"<< endl;
                cin.getline (name,100);
                cout<<"Hello, " << name << "."<<  endl;
				cout<<"Put in your current pl"<<endl;
				cin>> pl;
                cout<<"Put in your difficulty points:"<< endl; //asks for diff
                cin>> diff; //Receives difficulty and loads it into memory
                cout<<"Put in your creativity points:"<< endl;
                cin>> creat;
                cout<<"Put in your line count:"<< endl;
                cin>> lines;
                x = pl*(10*diff)+(10*creat)+(2*lines);
                y = x/150*(log*(pl/1.5)); 
				z = pl+y;
                cout<<"Your Power level is " << z << ".\a" << endl;
                cout<<""<< endl;
                cout<<"Q - Quit"<< endl;
                cout<<"R - Repeat"<< endl;
                cout<<"Please type in the corresponding letter for your choice then press enter."<< endl;
                cin>> quit;
                cout<<"Goodbye, " << name << "."<< endl;

        return 0;

Surely you meant


I removed the multiplication sign after 'log' (which made it treated like a variable instead of a function name).

Also, as you wrote it, log(pl/1.5) would have been on the top of the fraction, so I added parentheses to put it on the bottom. (Which by your original post's ASCII art I assumed you wanted.)

Hmmm, now it says 'error C2064: term does not evaluate to a function' =/

Try x/(150*log((double)(pl/1.5))); since log takes a double as its argument.

Hmmm it still gives the same error =/ how can it be made to evaluate?

the probleme is that you have declared log as a float. and a float is not a function and a float variable cant be used as a function.
so ether change (150*log(pl/1.5)); to (150*std::log(pl/1.5));
or remove the log float.

Awesome its building now, thanks alot =D

Bah namespaces. Use std::log instead of log.

Thanks for the help guys, but i need to find the natural log, that 'log' function is the common log, how can i get the natural log, ln, in?

log(x) is the natural logarithm of x (base e)
log10(x) is the common logarithm of x (base 10)

Yah, it's time to get used to the idea that the natural log is called both "ln" and "log", and that the common logarithm is called "log" and "log10". For extra fun, find a teacher that writes "ln" while speaking "log"!

So i use 'log10' instead of log? Is 'log10' the Ln?

I have an idea. Try testing the functions.

What functions? =/
I thought log10 was right but its not, there must be another way to include the natural logarithm >_<

log(x) ; returns the natural log of x, accept it.
Are you sure that you are thinking of log?
can you give us a couple of examples of wath you want to be done?
Guessing wath you want is hard.

natural log:
log(3) = 1,0986122886681096913952452369225
log(10) = 2,3025850929940456840179914546844
log(20) = 2,9957322735539909934352235761425
log(100 = 4,6051701859880913680359829093687

common log:
log10(3) = 0,47712125471966243729502790325512
log10(10) = 1
log10(20) = 1,3010299956639811952137388947245
log10(100) = 2

I have taken a closer look on your code, and think I see wher your error is.
y = x/150*(log(pl/1.5));
y = x/(150*(log(pl/1.5)));
are 2 completly diferent calculation. this might be your error.
and the last is the corect one, at last from your formula.

I found out why, the log was correct all along lol, the problem was in the 'x' part of the formula, i made a parenthetical error on the first line, this was my line:
x = pl*(10*diff)+(10*creat)+(2*lines);
and this is the correct version:
x = pl*((10*diff)+(10*creat)+(2*lines));
which explains why the log wasnt functioning correctly, thanks alot for your help guys ^^