Question 4
Back to Exercise
What is the output of the following C++ program?
#include <iostream>
int main() {
std::cout << std::hex << 10 << ' ' << 16 << ' ';
std::cout << 255 << ' ' << std::dec << 255 << '\n';
return 0;
}
- A a 10 ff 255 Correct
- B a 16 255 255
- C a 10 255 255
- D 10 16 ff 255
Correct Answer: Option A
Once std::hex is inserted, every integer is printed in hex – even in the next statement – until std::dec switches back.
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!