I wanna know if it is possible to use the scientific notation with variables?
For example:
int n;
cin >> n;
int x = 1en;
instead of
int x = 1e8
Is it possible? If yes, how?
No. Scientific notation is only for constant values. Those values are determined at compile time, while the value you want to get is determined at runtime.
You'll have to use something like int result = pow(10,n)
. Keep in mind that std::pow
returns double values.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With