0

The formula is as follows:

'formula: pl * (10*diff + 10*creat +2*lines)

------------------------------------------

150 * (Ln(pl/1.5))'

Can anyone help?

Answered # Algebraic question

Discussion Starter Mike182 Rashakil Fol 978 Discussion Starter Mike182 zyruz Discussion Starter Mike182 zyruz Rashakil Fol 978 Discussion Starter Mike182 zyruz zyruz Discussion Starter Mike182 Write a C program that should create a 10 element array of random integers (0 to 9). The program should total all of the numbers in the odd positions of the array and compare them with the total of the numbers in the even positions of the array and indicate ...

0

The formula is as follows:

'formula: pl * (10*diff + 10*creat +2*lines)

------------------------------------------

150 * (Ln(pl/1.5))'

Can anyone help?

0

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;
system("PAUSE");
system("cls");
}
return 0;
}
```

0

Surely you meant

`x/(150*log(pl/1.5));`

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.)

0

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

0

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.

0

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?

0

log(x) is the natural logarithm of x (base e)

log10(x) is the common logarithm of x (base 10)

0

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"!

0

What functions? =/

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

0

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

0

I have taken a closer look on your code, and think I see wher your error is.

y = x/150*(log(pl/1.5));

and

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.

0

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 ^^

This question has already been answered. Start a new discussion instead.

Recommended Articles

the function that I created to find the ...

Hi. so this is actually a continuation from another question of mineHere but i was advised to start a new thread as the original question was already answered.

This is the result of previous question answered :

code for the listbox - datagridview interaction

At the top of the code ...