create function that finds base log

i need help im not getting the correct results


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

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

using namespace std;

/*
*
*/

double thelog(double base, double x) {
return (double)(log(x) / log(base));
}

int main() {

double base;
double x;
double log(x);
cout << "Please enter the base must be greater than 0 " << endl;
cin >> base;
cout << "Please enter the base must be greater than 0" << endl;
cin >> x;
double thelog(double base, double x);
cout << thelog(base, x);













return 0;
}

Please use code tags.
http://www.cplusplus.com/articles/jEywvCM9/

1
2
3
4
5
6
7
8
9
10
11
/*
Declaring a double called log and using 
functional notation to initialise it to x
*/
double log(x);

/*
Declaring a function called thelog taking in two doubles
and returning a double.
*/
double thelog(double base, double x);

I don't think this is doing what you think it is.

 
return (double)(log(x) / log(base));

No need to cast to a double.

Revise on the basics.
http://www.cplusplus.com/doc/tutorial/variables/
http://www.cplusplus.com/doc/tutorial/functions/

edit:
It's working fine for me.

Please enter the base must be greater than 0 
2
Please enter the base must be greater than 0
10
3.32193 
Last edited on
its not giving me correct math
its not giving me correct math
Make sure that the prompts:
"Please enter the base must be greater than 0 "
and
"Please enter the base must be greater than 0"
are meaningful so that both the programmer and the end-user knows which parameter is which.
Topic archived. No new replies allowed.