Question
please program this using c++ Write a program to find the mystery base in the following equation: 24 2 = 554 The mystery base is
please program this using c++
Write a program to find the mystery base in the following equation:
242 = 554
The mystery base is an integer greater than 5.
Your program must calculate the numbers represented on both sides of the above equation for different possible bases. For each base that is attempted, print out the values for both sides of the equation (in base 10). For example, if the base being attempted is 6, then 242 would be (2x6+4)2 = 16*16, or 256, and 554 would be (5x62 + 5x6 + 4) or 214. For base 6, your program would print:
base 6: 256 == 214
Your program would then try for base 7, and print:
base 7: ...
and so on.
When the correct base is found, the program should print what this mystery base is. At that time, it should stop searching for the base.
Finally, your program should contain two functions: int calc_lhs(b) and void calc_rhs(v, b) for calculating the left-hand-side and right-hand-side values of the equation, respectively. The argument 'b' is the value for the base. The function calc_lfs() returns the computed value for the given base of the left-hand-side. The argument 'v' in calc_rhs() is the value, which should be passed by reference. Note that calc_rhs() does not return a value, but modifies the variable 'v' passed to it instead. Therefore, in your main function, it would have something of the following wrapped inside a loop:
v1 = calc_lhs(b);
calc_rhs(v2, b);
cout << "base " << b << ": " << v1 << " == " << v2 << endl;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started