Help with computing log base

i need to write a program that computes log base b I'm getting these errors
main.cpp:28:10: error: called object type 'double' is not a function or function pointer
log = log( base)/log( num);
~~~^
main.cpp:28:21: error: called object type 'double' is not a function or function pointer
log = log( base)/log( num);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

/* 
* File: main.cpp
* Author: Guest
*
* Created on February 12, 2016, 11:04 PM
*/

#include <cstdlib>
#include <iostream>
#include <cmath>

using namespace std;

/*
* 
*/

int main() {

double base;
double num;
double log;
cout << "Please enter the base must be greater than 0 " << endl;
cin >> base;
cout << "Please enter a number must be greater than 0" << endl;
cin >> num;
log = log( base)/log( num);
cout << " The logarith base is " << log << endl;


return 0;
}
Not very smart naming the variable the same name as teh function "log". Just change name of the variable.

double logAnswer;


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/* 
* File: main.cpp
* Author: Guest
*
* Created on February 12, 2016, 11:04 PM
*/

#include <cstdlib>
#include <iostream>
#include <cmath>

using namespace std;

/*
* 
*/

int main() {

double base;
double num;
double logAnswer;
cout << "Please enter the base must be greater than 0 " << endl;
cin >> base;
cout << "Please enter a number must be greater than 0" << endl;
cin >> num;
logAnswer = log( base)/log( num);
cout << " The logarith base is " << logAnswer << endl;


return 0;
}

Last edited on
Topic archived. No new replies allowed.