Question 17
Back to Exercise
What is the output of the following C++ program on a 64-bit system?
#include <iostream>
int main() {
long long population = 1'428'627'663;
int mask = 0b1111'0000;
int hex = 0xFF'FF;
double precise = 3.141'592;
std::cout << population / 1'000'000 << ' ' << mask << ' ' << hex << ' ' << precise << '\n';
return 0;
}
- A 1428 240 65535 3.14159 Correct
- B 1428 11110000 65535 3.141'592
- C 1428627663 240 65535 3.14159
- D 1428 240 255 3.14159
Correct Answer: Option A
The ' separators (C++14) are ignored by the compiler. 0b1111'0000 is 240; cout prints doubles with 6 significant digits.
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!