0

Briefly explain what is bad though syntactically correct, about the code please

double i; cout << "Enter input: "; cin >> i; cout << "result 1 = " << pow(i, pow(cbrt(i), 3.0)) << endl; cout << "result 2 = " << i * i + 1 << endl; cout << "result 3 = " << i + 1 << endl;

14th Dec 2020, 3:16 PM
sarah johnathon
sarah johnathon - avatar
2 Answers
+ 2
Here is the code: https://code.sololearn.com/c7A18A19A9A3 Now can you please briefly explain what do you want to know?
14th Dec 2020, 4:11 PM
The future is now thanks to science
The future is now thanks to science - avatar
0
This code will only run when you issue `using namespace std;` somewhere in the beginning of code. As I have read from what some seniors here wrote, it was a bad practice once we start writing a large scope project where name conflict is a possibility. You forgot to #include <cmath> for std::cbrt(). (Personal opinion) I prefer to wrap expressions inside parentheses as much as possible (read: when I remember to), like so ... std::cout << "result 1 = " << ( ... ) << std::endl;
14th Dec 2020, 4:09 PM
Ipang