#include // Query the user for two integers, 'm' and 'n'. // // Determine whether 'm' is less than, equal to, or greater // than the cube root of 'n', and display the corresponding // message, so for example: // // -5 is less than the cube root of -100. // 3 is equal to the cube root of 27. // 12 is greater than the cube root of 1700. // // Do not use floating-point numbers and do not calculate a // cube root. Instead, use integer arithmetic and conditional // statements. // // Once you have received values of 'm' and 'n' from the user, // consider how you could determine the relationship between // // m and the cube root of n // // without actually calculating a cube root. // // Recall that cubing preserves the order of real numbers. // For example, if // // a < b, // // what can you say about // // a^3 and b^3? // // Use this observation to write an if--else-if--else statement // that determines which of the three messages to display. // int main(); int main() { return 0; } // Hint: // // Rather than checking whether // 3 ___ // m < \/ n // // compare the cube of 'm' with 'n'. Similarly, equality and // greater-than comparisons can be made using the cube of 'm'. // // Finally, consider whether your solution works for very large // positive or negative integers. What could happen when you // calculate the cube of 'm' using an int? /* * Solution: * * #include * * int main(); * * int main() { * int m{}; * int n{}; * * std::cout << "Enter an integer m: "; * std::cin >> m; * * std::cout << "Enter an integer n: "; * std::cin >> n; * * int m_cubed{ m*m*m }; * * if ( m_cubed < n ) { * std::cout << m << " is less than the cube root of " * << n << "." << std::endl; * } else if ( m_cubed == n ) { * std::cout << m << " is equal to the cube root of " * << n << "." << std::endl; * } else { * std::cout << m << " is greater than the cube root of " * << n << "." << std::endl; * } * * return 0; * } * * This solution does not necessarily work for very large positive * or negative values of 'm'. The expression m*m*m may exceed the * range that can be represented by an int. For signed integers, * such overflow results in undefined behavior in C++. */