Your program will prompt for a positive number to find the logarithm of. Finally, your program will output the logarithm base b of the number n. The main function will be responsible for getting the input from the user, outputting your name and description of the program, and computing the resulting logarithm.
For this project you must use a function from the cmath library. Specifically, when you implement the change of base formula you will want to use either the log (loge) or log10 (log10) function.
Your output should look exactly like the example below. The example below is for a base of 2 and a number 32
1
Please enter the base (must be greater than 0): 2
Please enter a number (must be greater than 0): 32
The logarithm base 2 of 32 is 5.
heres my code
to me
/*
* File: main.cpp
* Author: Zac
*
* Created on September 22, 2015, 10:04 AM
*/
cout << "Please enter the base (must be greater than 0)" << endl;
cin >> num1;
cout << "Please enter a number (must be greater than 0)" << endl;
cin >> num2;
cout << "The logarithm base 2 of 32 is :5";
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;
Ok...I don't see any significant updates other than a change in variable types...
Also rule of thumb: if you're not gonna call any methods in a specific library, don't #include them. I'm not seeing anything from iomanip and I highly doubt you're going to be needing methods within the cstdlib library.
The only things you'll actually need are iostream, std, and cmath.
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;
cout << log(base n) of X = ( log(base10) of X ) / ( log(base10) of N)
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;
cin >> log(base n) of X = ( log(base10) of X ) / ( log(base10) of N);
Alright. I highly doubt you read into any of the links I gave you. What I posted was not code; it was a formula for you to use as a reference when you're writing the code...
cout << "Please enter the base (must be greater than 0)" << endl;
cin >> base;
cout << base << endl;
cout << "Please enter a number (must be greater than 0)" << endl;
cin >> num;
cout << num << endl;
cout << "log(base 10) of base is: " << log(base) << endl;
cout << "log(base 10) of num is: " << log(num) << endl;
//cin >> log(base n) of X = ( log(base10) of X ) / ( log(base10) of N);