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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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 thatstd::powreturns double values.