This program will print out the logarithm of a number to a given base. Your prog
ID: 3541819 • Letter: T
Question
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.
Explanation / Answer
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
double number;
double base;
cout << "Enter positive floating point number :";
cin >> number;
cout << endl;
cout << "Enter positive floating point number that represents the base :";
cin >> base;
cout << endl;
cout << "log " <<number << " base " << base << " is given by " << log(number)/log(base) << endl;
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.