Question 17
Back to Exercise
What is the output of the following C++ program?
#include <iostream>
int main() {
std::cout << 1234567.0 << ' ' << 123456.0 << ' ' << 0.0001234 << ' ' << 100.0 << ' ' << 2.50 << '\n';
return 0;
}
- A 1.23457e+06 123456 0.0001234 100 2.5 Correct
- B 1234567 123456 0.0001234 100 2.50
- C 1.23457e+06 123456 1.234e-04 100.0 2.5
- D 1234567.0 123456.0 0.0001234 100.0 2.50
Correct Answer: Option A
Default notation uses 6 significant digits and switches to scientific when the number needs more than 6 digits before the point. Trailing zeros and the point of whole numbers are dropped.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!