Question 6
Back to Exercise
What is the output of the following C++ program?
#include <iostream>
int main() {
std::cout << std::showpos << 5 << ' ' << 0 << ' ' << -5 << std::noshowpos << ' ';
std::cout << (3 < 2) << ' ' << std::boolalpha << (3 < 2) << '\n';
return 0;
}
- A +5 +0 -5 0 false Correct
- B +5 0 -5 0 false
- C 5 0 -5 false false
- D +5 +0 -5 false false
Correct Answer: Option A
showpos adds + to non-negative numbers, including zero. bool prints as 0 until boolalpha is set.
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!