I\'ve asked this before but no one give me a working program or any clues to whe
ID: 3637641 • Letter: I
Question
I've asked this before but no one give me a working program or any clues to where I went wrong. Anyways here is the assignment:
This program will print out the logarithm of a number to a given base. Your program should read two numbers from standard input:
1. The first number is a positive floating point number for which your program will compute the logarithm.
2. The second number is a positive floating point number that represents the base to which the logarithm will be taken.
See page 93 in your book for a description of how to compute a logarithm to a particular base.
Your program should emit appropriate prompts and also include a description with its output. Shown below are two example runs, showing input and output.
should look like this
http://s52.photobucket.com/albums/g15/breakdancer122/?action=view¤t=do.jpg
This is the program that I wrote that doesn't work;
/*--------------------------------------------------------------------------*/
/* */
/* */
/* */
/* */
/* Author Lester Dela Cruz */
/* B19c - Jan 25, 2012 */
/* pp2_21.cpp */
#include <iostream> //Required for cout, endl.
#include <iomanip> //Required for setw() setprecision(), fixed.
#include <cmath> //Required for acos().
using namespace std;
const double ln(x), ln(b);
int main()
{
// Declare and initialize objects.
double x, b;
logb(x) = ln(x)/ln(b);
// Output on the screen
cout << "Enter a positive number: " << endl;
cin >> x;
//Output on the screen base
cout << "Enter a base: " << endl;
cin >> b;
//Output on the screen logb(x)
cout << x << "log of " << b << "is " << logb(x) << endl;
// Exit program
return 0;
}
I'm probably using wrong libraries, and getting confused in declaring things. Anyways can you write a program that does what it says in the picture? I wan't to see how you would do it.